@draftbit/core 48.4.8-618b68.2 → 48.4.8-a0f5d6.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.
- package/lib/commonjs/components/Picker/Picker.js +1 -1
- package/lib/commonjs/components/Picker/PickerInputContainer.js +1 -0
- package/lib/commonjs/utilities.js +1 -1
- package/lib/typescript/src/components/Picker/Picker.d.ts +1 -27
- package/lib/typescript/src/components/Picker/Picker.js +12 -28
- package/lib/typescript/src/components/Picker/Picker.js.map +1 -1
- package/lib/typescript/src/components/Picker/PickerCommon.d.ts +27 -0
- package/lib/typescript/src/components/Picker/PickerCommon.js +2 -0
- package/lib/typescript/src/components/Picker/PickerCommon.js.map +1 -0
- package/lib/typescript/src/components/Picker/PickerInputContainer.d.ts +9 -0
- package/lib/typescript/src/components/Picker/PickerInputContainer.js +26 -0
- package/lib/typescript/src/components/Picker/PickerInputContainer.js.map +1 -0
- package/lib/typescript/src/utilities.d.ts +4 -0
- package/lib/typescript/src/utilities.js +15 -1
- package/lib/typescript/src/utilities.js.map +1 -1
- package/lib/typescript/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -3
- package/src/components/Picker/Picker.js +12 -28
- package/src/components/Picker/Picker.js.map +1 -1
- package/src/components/Picker/Picker.tsx +22 -85
- package/src/components/Picker/PickerCommon.js +2 -0
- package/src/components/Picker/PickerCommon.js.map +1 -0
- package/src/components/Picker/PickerCommon.ts +30 -0
- package/src/components/Picker/PickerInputContainer.js +26 -0
- package/src/components/Picker/PickerInputContainer.js.map +1 -0
- package/src/components/Picker/PickerInputContainer.tsx +74 -0
- package/src/utilities.js +15 -1
- package/src/utilities.js.map +1 -1
- package/src/utilities.ts +22 -1
- package/lib/typescript/src/components/Picker/PickerTypes.d.ts +0 -18
- package/lib/typescript/src/components/Picker/PickerTypes.js +0 -2
- package/lib/typescript/src/components/Picker/PickerTypes.js.map +0 -1
- package/src/components/Picker/PickerTypes.js +0 -2
- package/src/components/Picker/PickerTypes.js.map +0 -1
- package/src/components/Picker/PickerTypes.ts +0 -18
- /package/lib/commonjs/components/Picker/{PickerTypes.js → PickerCommon.js} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));var _objectWithoutProperties2=_interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));var React=_interopRequireWildcard(require("react"));var _reactNative=require("react-native");var _lodash=require("lodash");var _reactNativeSafeAreaContext=require("react-native-safe-area-context");var _picker=require("@react-native-picker/picker");var _Portal=_interopRequireDefault(require("../Portal/Portal"));var _Button=require("../Button");var
|
|
1
|
+
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));var _objectWithoutProperties2=_interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));var React=_interopRequireWildcard(require("react"));var _reactNative=require("react-native");var _lodash=require("lodash");var _reactNativeSafeAreaContext=require("react-native-safe-area-context");var _picker=require("@react-native-picker/picker");var _Portal=_interopRequireDefault(require("../Portal/Portal"));var _Button=require("../Button");var _utilities=require("../../utilities");var _PickerInputContainer=_interopRequireDefault(require("./PickerInputContainer"));var _jsxRuntime=require("react/jsx-runtime");var _excluded=["options","onValueChange","Icon","placeholder","value","autoDismissKeyboard"];var _this=this,_jsxFileName="/home/runner/work/react-native-jigsaw/react-native-jigsaw/packages/core/src/components/Picker/Picker.tsx";function _getRequireWildcardCache(nodeInterop){if(typeof WeakMap!=="function")return null;var cacheBabelInterop=new WeakMap();var cacheNodeInterop=new WeakMap();return(_getRequireWildcardCache=function _getRequireWildcardCache(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop;})(nodeInterop);}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;}var isIos=_reactNative.Platform.OS==="ios";var isWeb=_reactNative.Platform.OS==="web";var Picker=function Picker(_ref){var _ref$options=_ref.options,optionsProp=_ref$options===void 0?[]:_ref$options,_onValueChange=_ref.onValueChange,Icon=_ref.Icon,placeholder=_ref.placeholder,value=_ref.value,_ref$autoDismissKeybo=_ref.autoDismissKeyboard,autoDismissKeyboard=_ref$autoDismissKeybo===void 0?true:_ref$autoDismissKeybo,rest=(0,_objectWithoutProperties2.default)(_ref,_excluded);var pickerRef=React.useRef(null);var _React$useState=React.useState(false),_React$useState2=(0,_slicedToArray2.default)(_React$useState,2),pickerVisible=_React$useState2[0],setPickerVisible=_React$useState2[1];var options=(0,_utilities.useDeepCompareMemo)(function(){var normalizedOptions=normalizeToPickerOptions(optionsProp);if(placeholder){return[{label:placeholder,value:placeholder}].concat(normalizedOptions);}else{return normalizedOptions;}},[placeholder,optionsProp]);if(!placeholder&&options.length&&!value&&value!==options[0].value){_onValueChange==null?void 0:_onValueChange(options[0].value);}var renderNativePicker=function renderNativePicker(){return(0,_jsxRuntime.jsx)(_picker.Picker,{ref:pickerRef,selectedValue:value,onValueChange:function onValueChange(newValue){if(newValue!==placeholder){_onValueChange==null?void 0:_onValueChange(newValue);}else if(newValue===placeholder){_onValueChange==null?void 0:_onValueChange("");}},style:[styles.nativePicker,isIos?styles.iosNativePicker:styles.nonIosPicker],onBlur:function onBlur(){return setPickerVisible(false);},children:options.map(function(option){return(0,_jsxRuntime.jsx)(_picker.Picker.Item,{label:option.label.toString(),value:option.value},option.value);})});};var renderPicker=function renderPicker(){if(isIos){return(0,_jsxRuntime.jsx)(_Portal.default,{children:(0,_jsxRuntime.jsx)(_reactNativeSafeAreaContext.SafeAreaView,{style:styles.nativePicker,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.iosPickerContent,children:[(0,_jsxRuntime.jsx)(_Button.Button,{Icon:Icon,type:"text",onPress:function onPress(){return setPickerVisible(!pickerVisible);},style:styles.iosButton,children:"Close"}),renderNativePicker()]})})});}else{return renderNativePicker();}};React.useEffect(function(){if(pickerVisible&&pickerRef.current){var _pickerRef$current;pickerRef==null?void 0:(_pickerRef$current=pickerRef.current)==null?void 0:_pickerRef$current.focus();}},[pickerVisible,pickerRef]);React.useEffect(function(){if(pickerVisible&&autoDismissKeyboard){_reactNative.Keyboard.dismiss();}},[pickerVisible,autoDismissKeyboard]);return(0,_jsxRuntime.jsx)(_PickerInputContainer.default,Object.assign({Icon:Icon,placeholder:placeholder,selectedValue:value,options:options,onPress:function onPress(){return setPickerVisible(!pickerVisible);}},rest,{children:(pickerVisible||isWeb)&&renderPicker()}));};var styles=_reactNative.StyleSheet.create({nativePicker:{position:"absolute",bottom:0,left:0,right:0,flexDirection:"row",justifyContent:"center",width:"100%",backgroundColor:"white"},iosPickerContent:{flexDirection:"column",width:"100%"},iosButton:{alignSelf:"flex-end"},iosNativePicker:{backgroundColor:"white"},nonIosPicker:{opacity:0}});function normalizeToPickerOptions(options){if(options.length===0){return[];}var firstOption=options[0];if(typeof firstOption===("string"||"number")){return options.map(function(option){return{label:option,value:option};});}if((0,_lodash.isObject)(firstOption)&&firstOption.value&&firstOption.label){return options.map(function(option){return{label:option.label,value:option.value};});}throw new Error('Picker options must be either an array of strings, numbers, or an array of { "label": string | number; "value": string | number; } objects.');}var _default=Picker;exports.default=_default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _objectWithoutProperties2=_interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));var _react=_interopRequireDefault(require("react"));var _reactNative=require("react-native");var _lodash=_interopRequireDefault(require("lodash.omit"));var _utilities=require("../../utilities");var _TextField=_interopRequireDefault(require("../TextField"));var _Touchable=_interopRequireDefault(require("../Touchable"));var _jsxRuntime=require("react/jsx-runtime");var _excluded=["options","onPress","Icon","style","placeholder","selectedValue","disabled","children"];var _this=this,_jsxFileName="/home/runner/work/react-native-jigsaw/react-native-jigsaw/packages/core/src/components/Picker/PickerInputContainer.tsx";var PickerInputContainer=function PickerInputContainer(_ref){var _options$find;var _ref$options=_ref.options,options=_ref$options===void 0?[]:_ref$options,onPress=_ref.onPress,Icon=_ref.Icon,style=_ref.style,placeholder=_ref.placeholder,selectedValue=_ref.selectedValue,_ref$disabled=_ref.disabled,disabled=_ref$disabled===void 0?false:_ref$disabled,children=_ref.children,rest=(0,_objectWithoutProperties2.default)(_ref,_excluded);var containerStyle=_reactNative.StyleSheet.flatten([(0,_utilities.extractSizeStyles)(style),(0,_utilities.extractPositionStyles)(style),(0,_utilities.extractFlexItemStyles)(style),(0,_utilities.extractBorderAndMarginStyles)(style).marginStyles]);var textFieldStyle=(0,_lodash.default)(_reactNative.StyleSheet.flatten(style),Object.keys(containerStyle));var selectedLabel=((_options$find=options.find(function(option){return option.value===selectedValue;}))==null?void 0:_options$find.label.toString())||selectedValue||placeholder;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:containerStyle,children:[(0,_jsxRuntime.jsx)(_Touchable.default,{disabled:disabled,onPress:onPress,children:(0,_jsxRuntime.jsx)(_TextField.default,Object.assign({Icon:Icon,numberOfLines:1,onChangeText:function onChangeText(){},value:selectedLabel==null?void 0:selectedLabel.toString(),editable:false,disabled:disabled,style:textFieldStyle},rest))}),children]});};var _default=PickerInputContainer;exports.default=_default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.applyStyles=applyStyles;exports.effectsStyleNames=exports.borderStyleNames=void 0;exports.extractBorderAndMarginStyles=extractBorderAndMarginStyles;exports.extractEffectStyles=extractEffectStyles;exports.extractFlexItemStyles=extractFlexItemStyles;exports.extractPositionStyles=extractPositionStyles;exports.extractSizeStyles=extractSizeStyles;exports.extractStyles=extractStyles;exports.flattenReactFragments=flattenReactFragments;exports.flexItemStyleNames=void 0;exports.getValueForRadioButton=getValueForRadioButton;exports.sizeStyleNames=exports.positionStyleNames=exports.marginStyleNames=void 0;var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));var _toConsumableArray2=_interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));var _objectWithoutProperties2=_interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));var _react=_interopRequireDefault(require("react"));var _reactNative=require("react-native");var _lodash=require("lodash");var _excluded=["color","fontFamily","fontWeight","fontSize","lineHeight","letterSpacing","textTransform","textAlign","textDecorationLine","textDecorationColor","textDecorationStyle"];function extractStyles(style){var _StyleSheet$flatten=_reactNative.StyleSheet.flatten(style||{}),color=_StyleSheet$flatten.color,fontFamily=_StyleSheet$flatten.fontFamily,fontWeight=_StyleSheet$flatten.fontWeight,fontSize=_StyleSheet$flatten.fontSize,lineHeight=_StyleSheet$flatten.lineHeight,letterSpacing=_StyleSheet$flatten.letterSpacing,textTransform=_StyleSheet$flatten.textTransform,textAlign=_StyleSheet$flatten.textAlign,textDecorationLine=_StyleSheet$flatten.textDecorationLine,textDecorationColor=_StyleSheet$flatten.textDecorationColor,textDecorationStyle=_StyleSheet$flatten.textDecorationStyle,viewStyles=(0,_objectWithoutProperties2.default)(_StyleSheet$flatten,_excluded);var textStyles={color:color,fontFamily:fontFamily,fontWeight:fontWeight,fontSize:fontSize,lineHeight:lineHeight,letterSpacing:letterSpacing,textTransform:textTransform,textAlign:textAlign,textDecorationLine:textDecorationLine,textDecorationColor:textDecorationColor,textDecorationStyle:textDecorationStyle};for(var key in textStyles){var styleKey=key;if(textStyles[styleKey]===undefined){delete textStyles[styleKey];}}return{viewStyles:viewStyles,textStyles:textStyles};}var borderStyleNames=["borderRadius","borderBottomColor","borderBottomEndRadius","borderBottomLeftRadius","borderBottomRightRadius","borderBottomStartRadius","borderBottomWidth","borderColor","borderEndColor","borderLeftColor","borderLeftWidth","borderRadius","borderRightColor","borderRightWidth","borderStartColor","borderStyle","borderTopColor","borderTopEndRadius","borderTopLeftRadius","borderTopRightRadius","borderTopStartRadius","borderTopWidth","borderWidth"];exports.borderStyleNames=borderStyleNames;var marginStyleNames=["margin","marginBottom","marginEnd","marginHorizontal","marginLeft","marginRight","marginStart","marginTop","marginVertical"];exports.marginStyleNames=marginStyleNames;function extractBorderAndMarginStyles(style,additionalBorderStyles,additionalMarginStyles){var flatStyle=_reactNative.StyleSheet.flatten(style||{});var borderStyles=(0,_lodash.pickBy)((0,_lodash.pick)(flatStyle,[].concat(borderStyleNames,(0,_toConsumableArray2.default)(additionalBorderStyles?additionalBorderStyles:[]))),_lodash.identity);var marginStyles=(0,_lodash.pickBy)((0,_lodash.pick)(flatStyle,[].concat(marginStyleNames,(0,_toConsumableArray2.default)(additionalMarginStyles?additionalMarginStyles:[]))),_lodash.identity);return{borderStyles:borderStyles,marginStyles:marginStyles};}var flexItemStyleNames=["alignSelf","flexBasis","flexShrink","flexGrow","flex"];exports.flexItemStyleNames=flexItemStyleNames;function extractFlexItemStyles(style,additionalFlexItemStyles){var flatStyle=_reactNative.StyleSheet.flatten(style||{});var flexItemStyles=(0,_lodash.pickBy)((0,_lodash.pick)(flatStyle,[].concat(flexItemStyleNames,(0,_toConsumableArray2.default)(additionalFlexItemStyles?additionalFlexItemStyles:[]))),_lodash.identity);return flexItemStyles;}var positionStyleNames=["position","left","right","top","bottom","zIndex","overflow"];exports.positionStyleNames=positionStyleNames;function extractPositionStyles(style,additionalPositionStyles){var flatStyle=_reactNative.StyleSheet.flatten(style||{});var positionStyles=(0,_lodash.pickBy)((0,_lodash.pick)(flatStyle,[].concat(positionStyleNames,(0,_toConsumableArray2.default)(additionalPositionStyles?additionalPositionStyles:[]))),_lodash.identity);return positionStyles;}var effectsStyleNames=["opacity","elevation"];exports.effectsStyleNames=effectsStyleNames;function extractEffectStyles(style,additionalEffectStyles){var flatStyle=_reactNative.StyleSheet.flatten(style||{});var effectStyles=(0,_lodash.pickBy)((0,_lodash.pick)(flatStyle,[].concat(effectsStyleNames,(0,_toConsumableArray2.default)(additionalEffectStyles?additionalEffectStyles:[]))),_lodash.identity);return effectStyles;}var sizeStyleNames=["width","height","minWidth","minHeight"];exports.sizeStyleNames=sizeStyleNames;function extractSizeStyles(style,additionalSizeStyles){var flatStyle=_reactNative.StyleSheet.flatten(style||{});var sizeStyles=(0,_lodash.pickBy)((0,_lodash.pick)(flatStyle,[].concat(sizeStyleNames,(0,_toConsumableArray2.default)(additionalSizeStyles?additionalSizeStyles:[]))),_lodash.identity);return sizeStyles;}function applyStyles(baseStyles,stylesToApply){if(!stylesToApply){return;}var flattenedStyles=_reactNative.StyleSheet.flatten(baseStyles);for(var _ref of Object.entries(stylesToApply)){var _ref2=(0,_slicedToArray2.default)(_ref,2);var key=_ref2[0];var value=_ref2[1];if(value!=null){flattenedStyles[key]=value;}}return flattenedStyles;}function getValueForRadioButton(value){if((0,_lodash.isString)(value)){return value;}else if((0,_lodash.isNumber)(value)){return String(value);}else{throw new Error("Invalid value: "+value);}}function flattenReactFragments(components){var flattened=[];for(var component of components){if(component.type===_react.default.Fragment){var _component$props;var children=_react.default.Children.toArray((_component$props=component.props)==null?void 0:_component$props.children);for(var child of children){flattened.push.apply(flattened,(0,_toConsumableArray2.default)(flattenReactFragments([child])));}}else{flattened.push(component);}}return flattened;}
|
|
1
|
+
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.applyStyles=applyStyles;exports.effectsStyleNames=exports.borderStyleNames=void 0;exports.extractBorderAndMarginStyles=extractBorderAndMarginStyles;exports.extractEffectStyles=extractEffectStyles;exports.extractFlexItemStyles=extractFlexItemStyles;exports.extractPositionStyles=extractPositionStyles;exports.extractSizeStyles=extractSizeStyles;exports.extractStyles=extractStyles;exports.flattenReactFragments=flattenReactFragments;exports.flexItemStyleNames=void 0;exports.getValueForRadioButton=getValueForRadioButton;exports.sizeStyleNames=exports.positionStyleNames=exports.marginStyleNames=void 0;exports.useDeepCompareMemo=useDeepCompareMemo;var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));var _toConsumableArray2=_interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));var _objectWithoutProperties2=_interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));var _react=_interopRequireDefault(require("react"));var _reactNative=require("react-native");var _lodash=require("lodash");var _excluded=["color","fontFamily","fontWeight","fontSize","lineHeight","letterSpacing","textTransform","textAlign","textDecorationLine","textDecorationColor","textDecorationStyle"];function extractStyles(style){var _StyleSheet$flatten=_reactNative.StyleSheet.flatten(style||{}),color=_StyleSheet$flatten.color,fontFamily=_StyleSheet$flatten.fontFamily,fontWeight=_StyleSheet$flatten.fontWeight,fontSize=_StyleSheet$flatten.fontSize,lineHeight=_StyleSheet$flatten.lineHeight,letterSpacing=_StyleSheet$flatten.letterSpacing,textTransform=_StyleSheet$flatten.textTransform,textAlign=_StyleSheet$flatten.textAlign,textDecorationLine=_StyleSheet$flatten.textDecorationLine,textDecorationColor=_StyleSheet$flatten.textDecorationColor,textDecorationStyle=_StyleSheet$flatten.textDecorationStyle,viewStyles=(0,_objectWithoutProperties2.default)(_StyleSheet$flatten,_excluded);var textStyles={color:color,fontFamily:fontFamily,fontWeight:fontWeight,fontSize:fontSize,lineHeight:lineHeight,letterSpacing:letterSpacing,textTransform:textTransform,textAlign:textAlign,textDecorationLine:textDecorationLine,textDecorationColor:textDecorationColor,textDecorationStyle:textDecorationStyle};for(var key in textStyles){var styleKey=key;if(textStyles[styleKey]===undefined){delete textStyles[styleKey];}}return{viewStyles:viewStyles,textStyles:textStyles};}var borderStyleNames=["borderRadius","borderBottomColor","borderBottomEndRadius","borderBottomLeftRadius","borderBottomRightRadius","borderBottomStartRadius","borderBottomWidth","borderColor","borderEndColor","borderLeftColor","borderLeftWidth","borderRadius","borderRightColor","borderRightWidth","borderStartColor","borderStyle","borderTopColor","borderTopEndRadius","borderTopLeftRadius","borderTopRightRadius","borderTopStartRadius","borderTopWidth","borderWidth"];exports.borderStyleNames=borderStyleNames;var marginStyleNames=["margin","marginBottom","marginEnd","marginHorizontal","marginLeft","marginRight","marginStart","marginTop","marginVertical"];exports.marginStyleNames=marginStyleNames;function extractBorderAndMarginStyles(style,additionalBorderStyles,additionalMarginStyles){var flatStyle=_reactNative.StyleSheet.flatten(style||{});var borderStyles=(0,_lodash.pickBy)((0,_lodash.pick)(flatStyle,[].concat(borderStyleNames,(0,_toConsumableArray2.default)(additionalBorderStyles?additionalBorderStyles:[]))),_lodash.identity);var marginStyles=(0,_lodash.pickBy)((0,_lodash.pick)(flatStyle,[].concat(marginStyleNames,(0,_toConsumableArray2.default)(additionalMarginStyles?additionalMarginStyles:[]))),_lodash.identity);return{borderStyles:borderStyles,marginStyles:marginStyles};}var flexItemStyleNames=["alignSelf","flexBasis","flexShrink","flexGrow","flex"];exports.flexItemStyleNames=flexItemStyleNames;function extractFlexItemStyles(style,additionalFlexItemStyles){var flatStyle=_reactNative.StyleSheet.flatten(style||{});var flexItemStyles=(0,_lodash.pickBy)((0,_lodash.pick)(flatStyle,[].concat(flexItemStyleNames,(0,_toConsumableArray2.default)(additionalFlexItemStyles?additionalFlexItemStyles:[]))),_lodash.identity);return flexItemStyles;}var positionStyleNames=["position","left","right","top","bottom","zIndex","overflow"];exports.positionStyleNames=positionStyleNames;function extractPositionStyles(style,additionalPositionStyles){var flatStyle=_reactNative.StyleSheet.flatten(style||{});var positionStyles=(0,_lodash.pickBy)((0,_lodash.pick)(flatStyle,[].concat(positionStyleNames,(0,_toConsumableArray2.default)(additionalPositionStyles?additionalPositionStyles:[]))),_lodash.identity);return positionStyles;}var effectsStyleNames=["opacity","elevation"];exports.effectsStyleNames=effectsStyleNames;function extractEffectStyles(style,additionalEffectStyles){var flatStyle=_reactNative.StyleSheet.flatten(style||{});var effectStyles=(0,_lodash.pickBy)((0,_lodash.pick)(flatStyle,[].concat(effectsStyleNames,(0,_toConsumableArray2.default)(additionalEffectStyles?additionalEffectStyles:[]))),_lodash.identity);return effectStyles;}var sizeStyleNames=["width","height","minWidth","minHeight"];exports.sizeStyleNames=sizeStyleNames;function extractSizeStyles(style,additionalSizeStyles){var flatStyle=_reactNative.StyleSheet.flatten(style||{});var sizeStyles=(0,_lodash.pickBy)((0,_lodash.pick)(flatStyle,[].concat(sizeStyleNames,(0,_toConsumableArray2.default)(additionalSizeStyles?additionalSizeStyles:[]))),_lodash.identity);return sizeStyles;}function applyStyles(baseStyles,stylesToApply){if(!stylesToApply){return;}var flattenedStyles=_reactNative.StyleSheet.flatten(baseStyles);for(var _ref of Object.entries(stylesToApply)){var _ref2=(0,_slicedToArray2.default)(_ref,2);var key=_ref2[0];var value=_ref2[1];if(value!=null){flattenedStyles[key]=value;}}return flattenedStyles;}function getValueForRadioButton(value){if((0,_lodash.isString)(value)){return value;}else if((0,_lodash.isNumber)(value)){return String(value);}else{throw new Error("Invalid value: "+value);}}function flattenReactFragments(components){var flattened=[];for(var component of components){if(component.type===_react.default.Fragment){var _component$props;var children=_react.default.Children.toArray((_component$props=component.props)==null?void 0:_component$props.children);for(var child of children){flattened.push.apply(flattened,(0,_toConsumableArray2.default)(flattenReactFragments([child])));}}else{flattened.push(component);}}return flattened;}function useDeepCompareMemoize(value){var ref=_react.default.useRef();if(!(0,_lodash.isEqual)(value,ref.current)){ref.current=value;}return ref.current;}function useDeepCompareMemo(factory,deps){return _react.default.useMemo(factory,deps==null?void 0:deps.map(useDeepCompareMemoize));}
|
|
@@ -1,30 +1,4 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import {
|
|
3
|
-
import type { IconSlot } from "../../interfaces/Icon";
|
|
4
|
-
export interface PickerOption {
|
|
5
|
-
value: string;
|
|
6
|
-
label: string;
|
|
7
|
-
}
|
|
8
|
-
export declare type PickerProps = {
|
|
9
|
-
error?: any;
|
|
10
|
-
placeholder?: string;
|
|
11
|
-
disabled?: boolean;
|
|
12
|
-
style?: StyleProp<ViewStyle> & {
|
|
13
|
-
height?: number;
|
|
14
|
-
};
|
|
15
|
-
value?: string;
|
|
16
|
-
options: PickerOption[] | string[];
|
|
17
|
-
onValueChange: (value: string) => void;
|
|
18
|
-
assistiveText?: string;
|
|
19
|
-
label?: string;
|
|
20
|
-
iconColor?: string;
|
|
21
|
-
iconSize?: number;
|
|
22
|
-
leftIconMode?: "inset" | "outset";
|
|
23
|
-
leftIconName?: string;
|
|
24
|
-
placeholderTextColor?: string;
|
|
25
|
-
rightIconName?: string;
|
|
26
|
-
type?: "solid" | "underline";
|
|
27
|
-
autoDismissKeyboard?: boolean;
|
|
28
|
-
} & IconSlot;
|
|
2
|
+
import { PickerProps } from "./PickerCommon";
|
|
29
3
|
declare const Picker: React.FC<PickerProps>;
|
|
30
4
|
export default Picker;
|
|
@@ -1,21 +1,18 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { View, StyleSheet, Platform, Keyboard
|
|
2
|
+
import { View, StyleSheet, Platform, Keyboard } from "react-native";
|
|
3
3
|
import { isObject } from "lodash";
|
|
4
4
|
import { SafeAreaView } from "react-native-safe-area-context";
|
|
5
5
|
import { Picker as NativePicker } from "@react-native-picker/picker";
|
|
6
6
|
import Portal from "../Portal/Portal";
|
|
7
7
|
import { Button } from "../Button";
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import TextField from "../TextField";
|
|
11
|
-
import omit from "lodash.omit";
|
|
8
|
+
import { useDeepCompareMemo } from "../../utilities";
|
|
9
|
+
import PickerInputContainer from "./PickerInputContainer";
|
|
12
10
|
const isIos = Platform.OS === "ios";
|
|
13
11
|
const isWeb = Platform.OS === "web";
|
|
14
|
-
const Picker = ({ options: optionsProp = [], onValueChange, Icon,
|
|
15
|
-
var _a;
|
|
12
|
+
const Picker = ({ options: optionsProp = [], onValueChange, Icon, placeholder, value, autoDismissKeyboard = true, ...rest }) => {
|
|
16
13
|
const pickerRef = React.useRef(null);
|
|
17
14
|
const [pickerVisible, setPickerVisible] = React.useState(false);
|
|
18
|
-
const options =
|
|
15
|
+
const options = useDeepCompareMemo(() => {
|
|
19
16
|
const normalizedOptions = normalizeToPickerOptions(optionsProp);
|
|
20
17
|
// Underlying Picker component defaults selection to first element when value is not provided (or undefined)
|
|
21
18
|
// Placholder must be the 1st option in order to allow selection of the 'actual' 1st option
|
|
@@ -30,16 +27,6 @@ const Picker = ({ options: optionsProp = [], onValueChange, Icon, style, placeho
|
|
|
30
27
|
if (!placeholder && options.length && !value && value !== options[0].value) {
|
|
31
28
|
onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(options[0].value);
|
|
32
29
|
}
|
|
33
|
-
const selectedLabel = ((_a = options.find((option) => option.value === String(value))) === null || _a === void 0 ? void 0 : _a.label) ||
|
|
34
|
-
value ||
|
|
35
|
-
placeholder;
|
|
36
|
-
const containerStyle = StyleSheet.flatten([
|
|
37
|
-
extractSizeStyles(style),
|
|
38
|
-
extractPositionStyles(style),
|
|
39
|
-
extractFlexItemStyles(style),
|
|
40
|
-
extractBorderAndMarginStyles(style).marginStyles,
|
|
41
|
-
]);
|
|
42
|
-
const textFieldStyle = omit(style, Object.keys(containerStyle));
|
|
43
30
|
const renderNativePicker = () => (React.createElement(NativePicker, { ref: pickerRef, selectedValue: value, onValueChange: (newValue) => {
|
|
44
31
|
if (newValue !== placeholder) {
|
|
45
32
|
onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(newValue);
|
|
@@ -50,7 +37,7 @@ const Picker = ({ options: optionsProp = [], onValueChange, Icon, style, placeho
|
|
|
50
37
|
}, style: [
|
|
51
38
|
styles.nativePicker,
|
|
52
39
|
isIos ? styles.iosNativePicker : styles.nonIosPicker,
|
|
53
|
-
], onBlur: () => setPickerVisible(false) }, options.map((option) => (React.createElement(NativePicker.Item, { label: option.label, value: option.value, key: option.value })))));
|
|
40
|
+
], onBlur: () => setPickerVisible(false) }, options.map((option) => (React.createElement(NativePicker.Item, { label: option.label.toString(), value: option.value, key: option.value })))));
|
|
54
41
|
const renderPicker = () => {
|
|
55
42
|
if (isIos) {
|
|
56
43
|
return (React.createElement(Portal, null,
|
|
@@ -74,10 +61,7 @@ const Picker = ({ options: optionsProp = [], onValueChange, Icon, style, placeho
|
|
|
74
61
|
Keyboard.dismiss();
|
|
75
62
|
}
|
|
76
63
|
}, [pickerVisible, autoDismissKeyboard]);
|
|
77
|
-
return (React.createElement(
|
|
78
|
-
React.createElement(Touchable, { disabled: disabled, onPress: () => setPickerVisible(!pickerVisible) },
|
|
79
|
-
React.createElement(TextField, { Icon: Icon, numberOfLines: 1, onChangeText: () => { }, value: String(selectedLabel !== null && selectedLabel !== void 0 ? selectedLabel : placeholder), editable: false, disabled: disabled, style: textFieldStyle, ...rest })),
|
|
80
|
-
(pickerVisible || isWeb) && renderPicker()));
|
|
64
|
+
return (React.createElement(PickerInputContainer, { Icon: Icon, placeholder: placeholder, selectedValue: value, options: options, onPress: () => setPickerVisible(!pickerVisible), ...rest }, (pickerVisible || isWeb) && renderPicker()));
|
|
81
65
|
};
|
|
82
66
|
const styles = StyleSheet.create({
|
|
83
67
|
nativePicker: {
|
|
@@ -111,19 +95,19 @@ function normalizeToPickerOptions(options) {
|
|
|
111
95
|
const firstOption = options[0];
|
|
112
96
|
if (typeof firstOption === ("string" || "number")) {
|
|
113
97
|
return options.map((option) => ({
|
|
114
|
-
label:
|
|
115
|
-
value:
|
|
98
|
+
label: option,
|
|
99
|
+
value: option,
|
|
116
100
|
}));
|
|
117
101
|
}
|
|
118
102
|
if (isObject(firstOption) && firstOption.value && firstOption.label) {
|
|
119
103
|
return options.map((option) => {
|
|
120
104
|
return {
|
|
121
|
-
label:
|
|
122
|
-
value:
|
|
105
|
+
label: option.label,
|
|
106
|
+
value: option.value,
|
|
123
107
|
};
|
|
124
108
|
});
|
|
125
109
|
}
|
|
126
|
-
throw new Error('Picker options must be either an array of strings or array of { "label": string; "value": string; } objects.');
|
|
110
|
+
throw new Error('Picker options must be either an array of strings, numbers, or an array of { "label": string | number; "value": string | number; } objects.');
|
|
127
111
|
}
|
|
128
112
|
export default Picker;
|
|
129
113
|
//# sourceMappingURL=Picker.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Picker.js","sourceRoot":"","sources":["../../../../../src/components/Picker/Picker.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,
|
|
1
|
+
{"version":3,"file":"Picker.js","sourceRoot":"","sources":["../../../../../src/components/Picker/Picker.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACpE,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAAE,MAAM,IAAI,YAAY,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,MAAM,MAAM,kBAAkB,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAErD,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAE1D,MAAM,KAAK,GAAG,QAAQ,CAAC,EAAE,KAAK,KAAK,CA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,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAE/B,IAAI,OAAO,WAAW,KAAK,CAAC,QAAQ,IAAI,QAAQ,CAAC,EAAE;QACjD,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;YAC9B,KAAK,EAAE,MAAyB;YAChC,KAAK,EAAE,MAAyB;SACjC,CAAC,CAAC,CAAC;KACL;IAED,IAAI,QAAQ,CAAC,WAAW,CAAC,IAAI,WAAW,CAAC,KAAK,IAAI,WAAW,CAAC,KAAK,EAAE;QACnE,OAAQ,OAA0B,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;YAChD,OAAO;gBACL,KAAK,EAAE,MAAM,CAAC,KAAK;gBACnB,KAAK,EAAE,MAAM,CAAC,KAAK;aACpB,CAAC;QACJ,CAAC,CAAC,CAAC;KACJ;IAED,MAAM,IAAI,KAAK,CACb,6IAA6I,CAC9I,CAAC;AACJ,CAAC;AAED,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { StyleProp, ViewStyle } from "react-native";
|
|
2
|
+
import { IconSlot } from "../../interfaces/Icon";
|
|
3
|
+
export interface PickerOption {
|
|
4
|
+
value: string | number;
|
|
5
|
+
label: string | number;
|
|
6
|
+
}
|
|
7
|
+
export interface PickerInputContainerProps extends IconSlot {
|
|
8
|
+
error?: any;
|
|
9
|
+
placeholder?: string;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
style?: StyleProp<ViewStyle>;
|
|
12
|
+
label?: string;
|
|
13
|
+
assistiveText?: string;
|
|
14
|
+
iconColor?: string;
|
|
15
|
+
iconSize?: number;
|
|
16
|
+
leftIconMode?: "inset" | "outset";
|
|
17
|
+
leftIconName?: string;
|
|
18
|
+
placeholderTextColor?: string;
|
|
19
|
+
rightIconName?: string;
|
|
20
|
+
type?: "solid" | "underline";
|
|
21
|
+
}
|
|
22
|
+
export interface PickerProps extends PickerInputContainerProps {
|
|
23
|
+
value?: string | number;
|
|
24
|
+
options: PickerOption[] | string[] | number[];
|
|
25
|
+
onValueChange: (value: string | number) => void;
|
|
26
|
+
autoDismissKeyboard?: boolean;
|
|
27
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PickerCommon.js","sourceRoot":"","sources":["../../../../../src/components/Picker/PickerCommon.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { PickerInputContainerProps as ExposedPickerInputContainerProps, PickerOption } from "./PickerCommon";
|
|
3
|
+
interface PickerInputContainerProps extends ExposedPickerInputContainerProps {
|
|
4
|
+
selectedValue?: string | number;
|
|
5
|
+
options: PickerOption[];
|
|
6
|
+
onPress?: () => void;
|
|
7
|
+
}
|
|
8
|
+
declare const PickerInputContainer: React.FC<React.PropsWithChildren<PickerInputContainerProps>>;
|
|
9
|
+
export default PickerInputContainer;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { View, StyleSheet } from "react-native";
|
|
3
|
+
import omit from "lodash.omit";
|
|
4
|
+
import { extractSizeStyles, extractPositionStyles, extractFlexItemStyles, extractBorderAndMarginStyles, } from "../../utilities";
|
|
5
|
+
import TextField from "../TextField";
|
|
6
|
+
import Touchable from "../Touchable";
|
|
7
|
+
const PickerInputContainer = ({ options = [], onPress, Icon, style, placeholder, selectedValue, disabled = false, children, ...rest }) => {
|
|
8
|
+
var _a;
|
|
9
|
+
const containerStyle = StyleSheet.flatten([
|
|
10
|
+
extractSizeStyles(style),
|
|
11
|
+
extractPositionStyles(style),
|
|
12
|
+
extractFlexItemStyles(style),
|
|
13
|
+
extractBorderAndMarginStyles(style).marginStyles,
|
|
14
|
+
]);
|
|
15
|
+
const textFieldStyle = omit(StyleSheet.flatten(style), Object.keys(containerStyle));
|
|
16
|
+
const selectedLabel = ((_a = options
|
|
17
|
+
.find((option) => option.value === selectedValue)) === null || _a === void 0 ? void 0 : _a.label.toString()) ||
|
|
18
|
+
selectedValue ||
|
|
19
|
+
placeholder;
|
|
20
|
+
return (React.createElement(View, { style: containerStyle },
|
|
21
|
+
React.createElement(Touchable, { disabled: disabled, onPress: onPress },
|
|
22
|
+
React.createElement(TextField, { Icon: Icon, numberOfLines: 1, onChangeText: () => { }, value: selectedLabel === null || selectedLabel === void 0 ? void 0 : selectedLabel.toString(), editable: false, disabled: disabled, style: textFieldStyle, ...rest })),
|
|
23
|
+
children));
|
|
24
|
+
};
|
|
25
|
+
export default PickerInputContainer;
|
|
26
|
+
//# sourceMappingURL=PickerInputContainer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PickerInputContainer.js","sourceRoot":"","sources":["../../../../../src/components/Picker/PickerInputContainer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,IAAI,MAAM,aAAa,CAAC;AAC/B,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACrB,4BAA4B,GAC7B,MAAM,iBAAiB,CAAC;AACzB,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,SAAS,MAAM,cAAc,CAAC;AAYrC,MAAM,oBAAoB,GAEtB,CAAC,EACH,OAAO,GAAG,EAAE,EACZ,OAAO,EACP,IAAI,EACJ,KAAK,EACL,WAAW,EACX,aAAa,EACb,QAAQ,GAAG,KAAK,EAChB,QAAQ,EACR,GAAG,IAAI,EACR,EAAE,EAAE;;IACH,MAAM,cAAc,GAAG,UAAU,CAAC,OAAO,CAAC;QACxC,iBAAiB,CAAC,KAAK,CAAC;QACxB,qBAAqB,CAAC,KAAK,CAAC;QAC5B,qBAAqB,CAAC,KAAK,CAAC;QAC5B,4BAA4B,CAAC,KAAK,CAAC,CAAC,YAAY;KACjD,CAAC,CAAC;IAEH,MAAM,cAAc,GAAG,IAAI,CACzB,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,EACzB,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,CAC5B,CAAC;IAEF,MAAM,aAAa,GACjB,CAAA,MAAA,OAAO;SACJ,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,KAAK,aAAa,CAAC,0CAC/C,KAAK,CAAC,QAAQ,EAAE;QACpB,aAAa;QACb,WAAW,CAAC;IAEd,OAAO,CACL,oBAAC,IAAI,IAAC,KAAK,EAAE,cAAc;QACzB,oBAAC,SAAS,IAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO;YAC7C,oBAAC,SAAS,IACR,IAAI,EAAE,IAAI,EACV,aAAa,EAAE,CAAC,EAChB,YAAY,EAAE,GAAG,EAAE,GAAE,CAAC,EACtB,KAAK,EAAE,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,QAAQ,EAAE,EAChC,QAAQ,EAAE,KAAK,EACf,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,cAAc,KACjB,IAAI,GACR,CACQ;QACX,QAAQ,CACJ,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
|
|
@@ -38,3 +38,7 @@ export declare function getValueForRadioButton(value: string | number): string;
|
|
|
38
38
|
* This is useful for operations that depend on a particular child type that would otherwise not match when wrapped in a fragment
|
|
39
39
|
*/
|
|
40
40
|
export declare function flattenReactFragments(components: React.ReactElement[]): React.ReactElement[];
|
|
41
|
+
/**
|
|
42
|
+
* useMemo counterpart that does a deep compare on the dependency list
|
|
43
|
+
*/
|
|
44
|
+
export declare function useDeepCompareMemo<T>(factory: () => T, deps: React.DependencyList | undefined): T;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { StyleSheet } from "react-native";
|
|
3
|
-
import { isString, isNumber, pick, pickBy, identity } from "lodash";
|
|
3
|
+
import { isString, isNumber, pick, pickBy, identity, isEqual } from "lodash";
|
|
4
4
|
export function extractStyles(style) {
|
|
5
5
|
const { color, fontFamily, fontWeight, fontSize, lineHeight, letterSpacing, textTransform, textAlign, textDecorationLine, textDecorationColor, textDecorationStyle, ...viewStyles } = StyleSheet.flatten(style || {});
|
|
6
6
|
const textStyles = {
|
|
@@ -177,4 +177,18 @@ export function flattenReactFragments(components) {
|
|
|
177
177
|
}
|
|
178
178
|
return flattened;
|
|
179
179
|
}
|
|
180
|
+
function useDeepCompareMemoize(value) {
|
|
181
|
+
const ref = React.useRef();
|
|
182
|
+
if (!isEqual(value, ref.current)) {
|
|
183
|
+
ref.current = value;
|
|
184
|
+
}
|
|
185
|
+
return ref.current;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* useMemo counterpart that does a deep compare on the dependency list
|
|
189
|
+
*/
|
|
190
|
+
export function useDeepCompareMemo(factory, deps) {
|
|
191
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
192
|
+
return React.useMemo(factory, deps === null || deps === void 0 ? void 0 : deps.map(useDeepCompareMemoize));
|
|
193
|
+
}
|
|
180
194
|
//# sourceMappingURL=utilities.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utilities.js","sourceRoot":"","sources":["../../../src/utilities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAwB,MAAM,cAAc,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"utilities.js","sourceRoot":"","sources":["../../../src/utilities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAwB,MAAM,cAAc,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,MA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