@react-querybuilder/native
Advanced tools
Comparing version 7.7.0-alpha.8 to 7.7.0
@@ -237,8 +237,2 @@ "use strict"; | ||
// src/components/NativeValueEditor.tsx | ||
var React6 = __toESM(require("react")); | ||
var import_react4 = require("react"); | ||
var import_react_native7 = require("react-native"); | ||
var import_react_querybuilder3 = require("react-querybuilder"); | ||
// src/components/NativeValueSelector.tsx | ||
var React5 = __toESM(require("react")); | ||
@@ -248,122 +242,28 @@ var import_react3 = require("react"); | ||
var import_react_querybuilder2 = require("react-querybuilder"); | ||
var NativeValueSelector = ({ | ||
handleOnChange, | ||
options: _options, | ||
value, | ||
disabled, | ||
multiple, | ||
listsAsArrays, | ||
schema, | ||
testID | ||
}) => { | ||
const styles = (0, import_react3.useMemo)(() => { | ||
if (testID === import_react_querybuilder2.TestID.combinators) { | ||
return { | ||
selector: import_react_native6.StyleSheet.flatten([ | ||
defaultNativeStyles.combinatorSelector, | ||
schema.styles?.combinatorSelector | ||
]), | ||
option: import_react_native6.StyleSheet.flatten([ | ||
defaultNativeStyles.combinatorOption, | ||
schema.styles?.combinatorOption | ||
]) | ||
}; | ||
} else if (testID === import_react_querybuilder2.TestID.fields) { | ||
return { | ||
selector: import_react_native6.StyleSheet.flatten([ | ||
defaultNativeStyles.fieldSelector, | ||
schema.styles?.fieldSelector | ||
]), | ||
option: import_react_native6.StyleSheet.flatten([defaultNativeStyles.fieldOption, schema.styles?.fieldOption]) | ||
}; | ||
} else if (testID === import_react_querybuilder2.TestID.operators) { | ||
return { | ||
selector: import_react_native6.StyleSheet.flatten([ | ||
defaultNativeStyles.operatorSelector, | ||
schema.styles?.operatorSelector | ||
]), | ||
option: import_react_native6.StyleSheet.flatten([ | ||
defaultNativeStyles.operatorOption, | ||
schema.styles?.operatorOption | ||
]) | ||
}; | ||
} else if (testID === import_react_querybuilder2.TestID.valueSourceSelector) { | ||
return { | ||
selector: import_react_native6.StyleSheet.flatten([ | ||
defaultNativeStyles.valueSourceSelector, | ||
schema.styles?.valueSourceSelector | ||
]), | ||
option: import_react_native6.StyleSheet.flatten([ | ||
defaultNativeStyles.valueSourceOption, | ||
schema.styles?.valueSourceOption | ||
]) | ||
}; | ||
} else if (testID === import_react_querybuilder2.TestID.valueEditor) { | ||
return { | ||
selector: import_react_native6.StyleSheet.flatten([ | ||
defaultNativeStyles.valueEditorSelector, | ||
schema.styles?.valueEditorSelector | ||
]), | ||
option: import_react_native6.StyleSheet.flatten([ | ||
defaultNativeStyles.valueEditorOption, | ||
schema.styles?.valueEditorOption | ||
]) | ||
}; | ||
} | ||
return import_react_native6.StyleSheet.create(defaultNativeSelectStyles); | ||
}, [ | ||
schema.styles?.combinatorOption, | ||
schema.styles?.combinatorSelector, | ||
schema.styles?.fieldOption, | ||
schema.styles?.fieldSelector, | ||
schema.styles?.operatorOption, | ||
schema.styles?.operatorSelector, | ||
schema.styles?.valueEditorOption, | ||
schema.styles?.valueEditorSelector, | ||
schema.styles?.valueSourceOption, | ||
schema.styles?.valueSourceSelector, | ||
testID | ||
]); | ||
const { onChange } = (0, import_react_querybuilder2.useValueSelector)({ handleOnChange, listsAsArrays, multiple, value }); | ||
const val = multiple ? Array.isArray(value) ? (0, import_react_querybuilder2.joinWith)(value, ",") : value : value; | ||
return /* @__PURE__ */ React5.createElement( | ||
import_react_native6.TextInput, | ||
{ | ||
testID, | ||
"aria-disabled": disabled, | ||
style: styles.selector, | ||
value: val, | ||
onChangeText: onChange | ||
} | ||
); | ||
}; | ||
// src/components/NativeValueEditor.tsx | ||
var NativeValueEditor = ({ | ||
operator, | ||
value, | ||
handleOnChange, | ||
title, | ||
className, | ||
type = "text", | ||
inputType = "text", | ||
values = [], | ||
listsAsArrays, | ||
parseNumbers, | ||
fieldData, | ||
disabled, | ||
separator = null, | ||
skipHook = false, | ||
testID, | ||
selectorComponent: SelectorComponent = NativeValueSelector, | ||
...props | ||
}) => { | ||
const styles = (0, import_react4.useMemo)( | ||
var NativeValueEditor = (allProps) => { | ||
const { | ||
operator, | ||
value, | ||
handleOnChange, | ||
title, | ||
className, | ||
type = "text", | ||
inputType = "text", | ||
values = [], | ||
listsAsArrays, | ||
fieldData, | ||
disabled, | ||
separator = null, | ||
testID, | ||
selectorComponent: SelectorComponent = allProps.schema.controls.valueSelector, | ||
...props | ||
} = allProps; | ||
const styles = (0, import_react3.useMemo)( | ||
() => ({ | ||
value: import_react_native7.StyleSheet.flatten([defaultNativeStyles.value, props.schema.styles?.value]), | ||
valueEditorSwitch: import_react_native7.StyleSheet.flatten([ | ||
value: import_react_native6.StyleSheet.flatten([defaultNativeStyles.value, props.schema.styles?.value]), | ||
valueEditorSwitch: import_react_native6.StyleSheet.flatten([ | ||
defaultNativeStyles.valueEditorSwitch, | ||
props.schema.styles?.valueEditorSwitch | ||
]), | ||
valueList: import_react_native7.StyleSheet.flatten([ | ||
valueList: import_react_native6.StyleSheet.flatten([ | ||
defaultNativeStyles.valueList, | ||
@@ -379,13 +279,3 @@ props.schema.styles?.valueList | ||
); | ||
const { valueAsArray, multiValueHandler, parseNumberMethod } = (0, import_react_querybuilder3.useValueEditor)({ | ||
skipHook, | ||
handleOnChange, | ||
inputType, | ||
operator, | ||
value, | ||
type, | ||
listsAsArrays, | ||
parseNumbers, | ||
values | ||
}); | ||
const { valueAsArray, multiValueHandler, parseNumberMethod } = (0, import_react_querybuilder2.useValueEditor)(allProps); | ||
if (operator === "null" || operator === "notNull") { | ||
@@ -399,4 +289,4 @@ return null; | ||
if (type === "text") { | ||
return /* @__PURE__ */ React6.createElement( | ||
import_react_native7.TextInput, | ||
return /* @__PURE__ */ React5.createElement( | ||
import_react_native6.TextInput, | ||
{ | ||
@@ -412,3 +302,3 @@ key, | ||
} | ||
return /* @__PURE__ */ React6.createElement( | ||
return /* @__PURE__ */ React5.createElement( | ||
SelectorComponent, | ||
@@ -421,3 +311,3 @@ { | ||
disabled, | ||
value: valueAsArray[i] ?? (0, import_react_querybuilder3.getFirstOption)(values), | ||
value: valueAsArray[i] ?? (0, import_react_querybuilder2.getFirstOption)(values), | ||
options: values, | ||
@@ -428,3 +318,3 @@ listsAsArrays | ||
}); | ||
return /* @__PURE__ */ React6.createElement(import_react_native7.View, { testID, style: styles.valueList }, editors[0], separator, editors[1]); | ||
return /* @__PURE__ */ React5.createElement(import_react_native6.View, { testID, style: styles.valueList }, editors[0], separator, editors[1]); | ||
} | ||
@@ -434,3 +324,3 @@ switch (type) { | ||
case "multiselect": | ||
return /* @__PURE__ */ React6.createElement( | ||
return /* @__PURE__ */ React5.createElement( | ||
SelectorComponent, | ||
@@ -451,4 +341,4 @@ { | ||
case "textarea": | ||
return /* @__PURE__ */ React6.createElement( | ||
import_react_native7.TextInput, | ||
return /* @__PURE__ */ React5.createElement( | ||
import_react_native6.TextInput, | ||
{ | ||
@@ -464,4 +354,4 @@ testID, | ||
case "checkbox": | ||
return /* @__PURE__ */ React6.createElement( | ||
import_react_native7.Switch, | ||
return /* @__PURE__ */ React5.createElement( | ||
import_react_native6.Switch, | ||
{ | ||
@@ -476,4 +366,4 @@ testID, | ||
} | ||
return /* @__PURE__ */ React6.createElement( | ||
import_react_native7.TextInput, | ||
return /* @__PURE__ */ React5.createElement( | ||
import_react_native6.TextInput, | ||
{ | ||
@@ -485,3 +375,3 @@ testID, | ||
value, | ||
onChangeText: (v) => handleOnChange((0, import_react_querybuilder3.parseNumber)(v, { parseNumbers: parseNumberMethod })) | ||
onChangeText: (v) => handleOnChange((0, import_react_querybuilder2.parseNumber)(v, { parseNumbers: parseNumberMethod })) | ||
} | ||
@@ -496,2 +386,108 @@ ); | ||
var React7 = __toESM(require("react")); | ||
// src/components/NativeValueSelector.tsx | ||
var React6 = __toESM(require("react")); | ||
var import_react4 = require("react"); | ||
var import_react_native7 = require("react-native"); | ||
var import_react_querybuilder3 = require("react-querybuilder"); | ||
var NativeValueSelector = ({ | ||
handleOnChange, | ||
options: _options, | ||
value, | ||
disabled, | ||
multiple, | ||
listsAsArrays, | ||
schema, | ||
testID | ||
}) => { | ||
const styles = (0, import_react4.useMemo)(() => { | ||
switch (testID) { | ||
case import_react_querybuilder3.TestID.combinators: { | ||
return { | ||
selector: import_react_native7.StyleSheet.flatten([ | ||
defaultNativeStyles.combinatorSelector, | ||
schema.styles?.combinatorSelector | ||
]), | ||
option: import_react_native7.StyleSheet.flatten([ | ||
defaultNativeStyles.combinatorOption, | ||
schema.styles?.combinatorOption | ||
]) | ||
}; | ||
} | ||
case import_react_querybuilder3.TestID.fields: { | ||
return { | ||
selector: import_react_native7.StyleSheet.flatten([ | ||
defaultNativeStyles.fieldSelector, | ||
schema.styles?.fieldSelector | ||
]), | ||
option: import_react_native7.StyleSheet.flatten([defaultNativeStyles.fieldOption, schema.styles?.fieldOption]) | ||
}; | ||
} | ||
case import_react_querybuilder3.TestID.operators: { | ||
return { | ||
selector: import_react_native7.StyleSheet.flatten([ | ||
defaultNativeStyles.operatorSelector, | ||
schema.styles?.operatorSelector | ||
]), | ||
option: import_react_native7.StyleSheet.flatten([ | ||
defaultNativeStyles.operatorOption, | ||
schema.styles?.operatorOption | ||
]) | ||
}; | ||
} | ||
case import_react_querybuilder3.TestID.valueSourceSelector: { | ||
return { | ||
selector: import_react_native7.StyleSheet.flatten([ | ||
defaultNativeStyles.valueSourceSelector, | ||
schema.styles?.valueSourceSelector | ||
]), | ||
option: import_react_native7.StyleSheet.flatten([ | ||
defaultNativeStyles.valueSourceOption, | ||
schema.styles?.valueSourceOption | ||
]) | ||
}; | ||
} | ||
case import_react_querybuilder3.TestID.valueEditor: { | ||
return { | ||
selector: import_react_native7.StyleSheet.flatten([ | ||
defaultNativeStyles.valueEditorSelector, | ||
schema.styles?.valueEditorSelector | ||
]), | ||
option: import_react_native7.StyleSheet.flatten([ | ||
defaultNativeStyles.valueEditorOption, | ||
schema.styles?.valueEditorOption | ||
]) | ||
}; | ||
} | ||
default: | ||
} | ||
return import_react_native7.StyleSheet.create(defaultNativeSelectStyles); | ||
}, [ | ||
schema.styles?.combinatorOption, | ||
schema.styles?.combinatorSelector, | ||
schema.styles?.fieldOption, | ||
schema.styles?.fieldSelector, | ||
schema.styles?.operatorOption, | ||
schema.styles?.operatorSelector, | ||
schema.styles?.valueEditorOption, | ||
schema.styles?.valueEditorSelector, | ||
schema.styles?.valueSourceOption, | ||
schema.styles?.valueSourceSelector, | ||
testID | ||
]); | ||
const { onChange } = (0, import_react_querybuilder3.useValueSelector)({ handleOnChange, listsAsArrays, multiple, value }); | ||
const val = multiple ? Array.isArray(value) ? (0, import_react_querybuilder3.joinWith)(value, ",") : value : value; | ||
return /* @__PURE__ */ React6.createElement( | ||
import_react_native7.TextInput, | ||
{ | ||
testID, | ||
"aria-disabled": disabled, | ||
style: styles.selector, | ||
value: val, | ||
onChangeText: onChange | ||
} | ||
); | ||
}; | ||
// src/components/NativeValueSelectorWeb.tsx | ||
var NativeValueSelectorWeb = (props) => /* @__PURE__ */ React7.createElement(NativeValueSelector, { ...props }); | ||
@@ -498,0 +494,0 @@ |
@@ -1,2 +0,2 @@ | ||
"use strict";var Pe=Object.create;var I=Object.defineProperty;var Be=Object.getOwnPropertyDescriptor;var we=Object.getOwnPropertyNames;var Ve=Object.getPrototypeOf,Ae=Object.prototype.hasOwnProperty;var Qe=(t,o)=>{for(var e in o)I(t,e,{get:o[e],enumerable:!0})},ae=(t,o,e,i)=>{if(o&&typeof o=="object"||typeof o=="function")for(let s of we(o))!Ae.call(t,s)&&s!==e&&I(t,s,{get:()=>o[s],enumerable:!(i=Be(o,s))||i.enumerable});return t};var d=(t,o,e)=>(e=t!=null?Pe(Ve(t)):{},ae(o||!t||!t.__esModule?I(e,"default",{value:t,enumerable:!0}):e,t)),Ie=t=>ae(I({},"__esModule",{value:!0}),t);var Xe={};Qe(Xe,{NativeActionElement:()=>y,NativeInlineCombinator:()=>z,NativeNotToggle:()=>K,NativeShiftActions:()=>Y,NativeValueEditor:()=>V,NativeValueEditorWeb:()=>Z,NativeValueSelector:()=>m,NativeValueSelectorWeb:()=>x,QueryBuilderNative:()=>Je,RuleGroupNative:()=>ee,RuleNative:()=>oe,defaultNativeControlElements:()=>J,defaultNativeSelectStyles:()=>u,defaultNativeStyles:()=>r,defaultNativeWebControlElements:()=>Le});module.exports=Ie(Xe);var D=d(require("react")),C=require("react-native");var ue=require("react-native"),u={selector:{borderRadius:4,borderWidth:1,height:32,width:100,paddingLeft:4},option:{}},De={actionElement:{borderWidth:1,borderRadius:4,height:32,padding:8,paddingBottom:4,paddingTop:4},actionElementText:{},combinatorOption:u.option,combinatorSelector:u.selector,dragHandle:{},fieldOption:u.option,fieldSelector:u.selector,inlineCombinator:{},notToggle:{flexDirection:"row"},notToggleLabel:{},notToggleSwitch:{},operatorOption:u.option,operatorSelector:u.selector,rule:{flexDirection:"row",gap:10,alignItems:"center"},ruleGroup:{backgroundColor:"rgba(0, 75, 183, 0.2)",borderColor:"#8081a2",borderRadius:4,borderWidth:1,padding:10,gap:10},ruleGroupBody:{gap:10},ruleGroupHeader:{flexDirection:"row",gap:10,alignItems:"center"},shiftActions:{flexDirection:"column"},value:{...u.selector,width:150},valueEditorOption:u.option,valueEditorSelector:u.selector,valueEditorSwitch:{},valueList:{flexDirection:"row"},valueSourceOption:u.option,valueSourceSelector:u.selector},r=ue.StyleSheet.create(De);var y=({handleOnClick:t,label:o,disabled:e,disabledTranslation:i,testID:s,schema:a})=>D.createElement(C.Pressable,{testID:s,disabled:e&&!i,onPress:l=>t()},D.createElement(C.View,{style:r.actionElement},D.createElement(C.Text,{style:r.actionElementText},`${i&&e?i.label??"":o??""}`)));var U=d(require("react")),pe=require("react"),L=require("react-native"),$=require("react-querybuilder");var z=({component:t,path:o,...e})=>{let i=(0,pe.useMemo)(()=>({inlineCombinator:L.StyleSheet.flatten([r.inlineCombinator,e.schema.styles?.inlineCombinator])}),[e.schema.styles?.inlineCombinator]);return U.createElement(L.View,{style:i.inlineCombinator,key:"no-dnd",testID:$.TestID.inlineCombinator},U.createElement(t,{...e,path:o,testID:$.TestID.combinators}))};var M=d(require("react")),me=require("react"),f=require("react-native");var K=({handleOnChange:t,label:o,checked:e,disabled:i,schema:s,testID:a})=>{let l=(0,me.useMemo)(()=>({notToggle:f.StyleSheet.flatten([r.notToggle,s.styles?.notToggle]),notToggleLabel:f.StyleSheet.flatten([r.notToggleLabel,s.styles?.notToggleLabel]),notToggleSwitch:f.StyleSheet.flatten([r.notToggleSwitch,s.styles?.notToggleSwitch])}),[s.styles?.notToggle,s.styles?.notToggleLabel,s.styles?.notToggleSwitch]);return M.createElement(f.View,{style:l.notToggle,testID:a},M.createElement(f.Text,{style:l.notToggleLabel},o),M.createElement(f.Switch,{style:l.notToggleSwitch,disabled:i,value:e,onValueChange:n=>t(n)}))};var O=d(require("react")),h=require("react-native");var Y=({shiftUp:t,shiftDown:o,shiftUpDisabled:e,shiftDownDisabled:i,disabled:s,labels:a,testID:l,schema:{styles:n}})=>{let G=O.useMemo(()=>({shiftActions:h.StyleSheet.flatten([r.shiftActions,n?.shiftActions])}),[n?.shiftActions]);return O.createElement(h.View,{testID:l,style:G.shiftActions},O.createElement(h.Button,{disabled:s||e,onPress:t,accessibilityLabel:a?.shiftUp,title:a?.shiftUp}),O.createElement(h.Button,{disabled:s||i,onPress:o,accessibilityLabel:a?.shiftDown,title:a?.shiftDown}))};var b=d(require("react")),ye=require("react"),c=require("react-native"),F=require("react-querybuilder");var ce=d(require("react")),de=require("react"),p=require("react-native"),S=require("react-querybuilder");var m=({handleOnChange:t,options:o,value:e,disabled:i,multiple:s,listsAsArrays:a,schema:l,testID:n})=>{let G=(0,de.useMemo)(()=>n===S.TestID.combinators?{selector:p.StyleSheet.flatten([r.combinatorSelector,l.styles?.combinatorSelector]),option:p.StyleSheet.flatten([r.combinatorOption,l.styles?.combinatorOption])}:n===S.TestID.fields?{selector:p.StyleSheet.flatten([r.fieldSelector,l.styles?.fieldSelector]),option:p.StyleSheet.flatten([r.fieldOption,l.styles?.fieldOption])}:n===S.TestID.operators?{selector:p.StyleSheet.flatten([r.operatorSelector,l.styles?.operatorSelector]),option:p.StyleSheet.flatten([r.operatorOption,l.styles?.operatorOption])}:n===S.TestID.valueSourceSelector?{selector:p.StyleSheet.flatten([r.valueSourceSelector,l.styles?.valueSourceSelector]),option:p.StyleSheet.flatten([r.valueSourceOption,l.styles?.valueSourceOption])}:n===S.TestID.valueEditor?{selector:p.StyleSheet.flatten([r.valueEditorSelector,l.styles?.valueEditorSelector]),option:p.StyleSheet.flatten([r.valueEditorOption,l.styles?.valueEditorOption])}:p.StyleSheet.create(u),[l.styles?.combinatorOption,l.styles?.combinatorSelector,l.styles?.fieldOption,l.styles?.fieldSelector,l.styles?.operatorOption,l.styles?.operatorSelector,l.styles?.valueEditorOption,l.styles?.valueEditorSelector,l.styles?.valueSourceOption,l.styles?.valueSourceSelector,n]),{onChange:X}=(0,S.useValueSelector)({handleOnChange:t,listsAsArrays:a,multiple:s,value:e}),W=s&&Array.isArray(e)?(0,S.joinWith)(e,","):e;return ce.createElement(p.TextInput,{testID:n,"aria-disabled":i,style:G.selector,value:W,onChangeText:X})};var V=({operator:t,value:o,handleOnChange:e,title:i,className:s,type:a="text",inputType:l="text",values:n=[],listsAsArrays:G,parseNumbers:X,fieldData:W,disabled:k,separator:Fe=null,skipHook:Te=!1,testID:B,selectorComponent:re=m,...v})=>{let w=(0,ye.useMemo)(()=>({value:c.StyleSheet.flatten([r.value,v.schema.styles?.value]),valueEditorSwitch:c.StyleSheet.flatten([r.valueEditorSwitch,v.schema.styles?.valueEditorSwitch]),valueList:c.StyleSheet.flatten([r.valueList,v.schema.styles?.valueList])}),[v.schema.styles?.value,v.schema.styles?.valueEditorSwitch,v.schema.styles?.valueList]),{valueAsArray:le,multiValueHandler:ie,parseNumberMethod:Ee}=(0,F.useValueEditor)({skipHook:Te,handleOnChange:e,inputType:l,operator:t,value:o,type:a,listsAsArrays:G,parseNumbers:X,values:n});if(t==="null"||t==="notNull")return null;let _=W?.placeholder??"",se=["in","notIn"].includes(t)?"text":l==="number"?"decimal":l??"text";if((t==="between"||t==="notBetween")&&(a==="select"||a==="text")){let N=["from","to"].map((ne,Q)=>a==="text"?b.createElement(c.TextInput,{key:ne,style:w.value,inputMode:se,placeholder:_,value:le[Q]??"",onChangeText:j=>ie(j,Q)}):b.createElement(re,{key:ne,...v,handleOnChange:j=>ie(j,Q),className:s,disabled:k,value:le[Q]??(0,F.getFirstOption)(n),options:n,listsAsArrays:G}));return b.createElement(c.View,{testID:B,style:w.valueList},N[0],Fe,N[1])}switch(a){case"select":case"multiselect":return b.createElement(re,{...v,testID:B,className:s,title:i,handleOnChange:e,disabled:k,value:o,options:n,multiple:a==="multiselect",listsAsArrays:G});case"textarea":return b.createElement(c.TextInput,{testID:B,style:w.value,placeholder:_,value:o,onChangeText:N=>e(N)});case"switch":case"checkbox":return b.createElement(c.Switch,{testID:B,style:w.valueEditorSwitch,disabled:k,value:!!o,onValueChange:N=>e(N)})}return b.createElement(c.TextInput,{testID:B,style:w.value,inputMode:se,placeholder:_,value:o,onChangeText:N=>e((0,F.parseNumber)(N,{parseNumbers:Ee}))})};var Se=d(require("react"));var fe=d(require("react"));var x=t=>fe.createElement(m,{...t});var Z=t=>Se.createElement(V,{...t,selectorComponent:x});var A=d(require("react")),Ce=require("react"),P=require("react-querybuilder"),Oe=require("react-redux");var be=require("react"),q=require("react-querybuilder");var T=d(require("react")),ve=require("react"),R=require("react-native"),g=require("react-querybuilder");var ee=t=>{let o=(0,g.useRuleGroup)(t),e=o.schema,i=(0,ve.useMemo)(()=>({ruleGroup:R.StyleSheet.flatten([r.ruleGroup,e.styles?.ruleGroup]),ruleGroupHeader:R.StyleSheet.flatten([r.ruleGroupHeader,e.styles?.ruleGroupHeader]),ruleGroupBody:R.StyleSheet.flatten([r.ruleGroupBody,e.styles?.ruleGroupBody])}),[e.styles?.ruleGroup,e.styles?.ruleGroupBody,e.styles?.ruleGroupHeader]);return T.createElement(R.View,{style:i.ruleGroup,testID:g.TestID.ruleGroup},T.createElement(R.View,{style:i.ruleGroupHeader},T.createElement(g.RuleGroupHeaderComponents,{...o})),T.createElement(R.View,{style:i.ruleGroupBody},T.createElement(g.RuleGroupBodyComponents,{...o})))};var te=d(require("react")),Ne=require("react"),H=require("react-native"),E=require("react-querybuilder");var oe=t=>{let o=(0,E.useRule)(t),e=o.schema,i=(0,Ne.useMemo)(()=>({rule:H.StyleSheet.flatten([r.rule,e.styles?.rule])}),[e.styles?.rule]);return te.createElement(H.View,{style:i.rule,testID:E.TestID.rule},te.createElement(E.RuleComponents,{...o}))};var J={actionElement:y,addGroupAction:y,addRuleAction:y,cloneGroupAction:y,cloneRuleAction:y,combinatorSelector:m,dragHandle:(0,be.forwardRef)(()=>null),fieldSelector:m,inlineCombinator:z,lockGroupAction:y,lockRuleAction:y,notToggle:K,operatorSelector:m,removeGroupAction:y,removeRuleAction:y,rule:oe,ruleGroup:ee,ruleGroupBodyElements:q.RuleGroupBodyComponents,ruleGroupHeaderElements:q.RuleGroupHeaderComponents,shiftActions:Y,valueEditor:V,valueSelector:m,valueSourceSelector:m},Le={...J,combinatorSelector:x,fieldSelector:x,operatorSelector:x,valueEditor:Z,valueSelector:m,valueSourceSelector:x};var xe=require("react"),Re=require("react-native"),ge=require("react-querybuilder"),Ge=require("react-querybuilder"),he=t=>Me(t,(0,ge.useQueryBuilderSetup)(t)),Me=(t,o)=>{let e=(0,Ge.useQueryBuilderSchema)(t,o),i=(0,xe.useMemo)(()=>Re.StyleSheet.create(t.styles??{}),[t.styles]);return{...e,schema:{...e.schema,styles:i}}};var He=[],qe=({props:t})=>{let o=(0,Ce.useMemo)(()=>({...J,...t.controlElements}),[t.controlElements]),e=he({...t,controlElements:o}),{ruleGroup:i}=e.schema.controls;return A.createElement(P.QueryBuilderContext.Provider,{value:e.rqbContext},A.createElement(i,{ruleGroup:e.rootGroup,...e.combinatorPropObject,path:He,translations:e.translations,schema:e.schema,actions:e.actions,id:e.rootGroup.id,disabled:e.rootGroupDisabled,parentDisabled:e.queryDisabled,context:t.context}))},Je=t=>A.createElement(Oe.Provider,{context:P.QueryBuilderStateContext,store:P.queryBuilderStore},A.createElement(qe,{props:t}));0&&(module.exports={NativeActionElement,NativeInlineCombinator,NativeNotToggle,NativeShiftActions,NativeValueEditor,NativeValueEditorWeb,NativeValueSelector,NativeValueSelectorWeb,QueryBuilderNative,RuleGroupNative,RuleNative,defaultNativeControlElements,defaultNativeSelectStyles,defaultNativeStyles,defaultNativeWebControlElements}); | ||
"use strict";var Ee=Object.create;var D=Object.defineProperty;var Pe=Object.getOwnPropertyDescriptor;var we=Object.getOwnPropertyNames;var Be=Object.getPrototypeOf,Ve=Object.prototype.hasOwnProperty;var Ae=(t,o)=>{for(var e in o)D(t,e,{get:o[e],enumerable:!0})},ne=(t,o,e,i)=>{if(o&&typeof o=="object"||typeof o=="function")for(let s of we(o))!Ve.call(t,s)&&s!==e&&D(t,s,{get:()=>o[s],enumerable:!(i=Pe(o,s))||i.enumerable});return t};var c=(t,o,e)=>(e=t!=null?Ee(Be(t)):{},ne(o||!t||!t.__esModule?D(e,"default",{value:t,enumerable:!0}):e,t)),Ie=t=>ne(D({},"__esModule",{value:!0}),t);var Je={};Ae(Je,{NativeActionElement:()=>d,NativeInlineCombinator:()=>z,NativeNotToggle:()=>K,NativeShiftActions:()=>Y,NativeValueEditor:()=>V,NativeValueEditorWeb:()=>Z,NativeValueSelector:()=>v,NativeValueSelectorWeb:()=>g,QueryBuilderNative:()=>qe,RuleGroupNative:()=>ee,RuleNative:()=>oe,defaultNativeControlElements:()=>X,defaultNativeSelectStyles:()=>a,defaultNativeStyles:()=>l,defaultNativeWebControlElements:()=>De});module.exports=Ie(Je);var L=c(require("react")),G=require("react-native");var ue=require("react-native"),a={selector:{borderRadius:4,borderWidth:1,height:32,width:100,paddingLeft:4},option:{}},Qe={actionElement:{borderWidth:1,borderRadius:4,height:32,padding:8,paddingBottom:4,paddingTop:4},actionElementText:{},combinatorOption:a.option,combinatorSelector:a.selector,dragHandle:{},fieldOption:a.option,fieldSelector:a.selector,inlineCombinator:{},notToggle:{flexDirection:"row"},notToggleLabel:{},notToggleSwitch:{},operatorOption:a.option,operatorSelector:a.selector,rule:{flexDirection:"row",gap:10,alignItems:"center"},ruleGroup:{backgroundColor:"rgba(0, 75, 183, 0.2)",borderColor:"#8081a2",borderRadius:4,borderWidth:1,padding:10,gap:10},ruleGroupBody:{gap:10},ruleGroupHeader:{flexDirection:"row",gap:10,alignItems:"center"},shiftActions:{flexDirection:"column"},value:{...a.selector,width:150},valueEditorOption:a.option,valueEditorSelector:a.selector,valueEditorSwitch:{},valueList:{flexDirection:"row"},valueSourceOption:a.option,valueSourceSelector:a.selector},l=ue.StyleSheet.create(Qe);var d=({handleOnClick:t,label:o,disabled:e,disabledTranslation:i,testID:s,schema:u})=>L.createElement(G.Pressable,{testID:s,disabled:e&&!i,onPress:r=>t()},L.createElement(G.View,{style:l.actionElement},L.createElement(G.Text,{style:l.actionElementText},`${i&&e?i.label??"":o??""}`)));var U=c(require("react")),pe=require("react"),M=require("react-native"),$=require("react-querybuilder");var z=({component:t,path:o,...e})=>{let i=(0,pe.useMemo)(()=>({inlineCombinator:M.StyleSheet.flatten([l.inlineCombinator,e.schema.styles?.inlineCombinator])}),[e.schema.styles?.inlineCombinator]);return U.createElement(M.View,{style:i.inlineCombinator,key:"no-dnd",testID:$.TestID.inlineCombinator},U.createElement(t,{...e,path:o,testID:$.TestID.combinators}))};var H=c(require("react")),me=require("react"),y=require("react-native");var K=({handleOnChange:t,label:o,checked:e,disabled:i,schema:s,testID:u})=>{let r=(0,me.useMemo)(()=>({notToggle:y.StyleSheet.flatten([l.notToggle,s.styles?.notToggle]),notToggleLabel:y.StyleSheet.flatten([l.notToggleLabel,s.styles?.notToggleLabel]),notToggleSwitch:y.StyleSheet.flatten([l.notToggleSwitch,s.styles?.notToggleSwitch])}),[s.styles?.notToggle,s.styles?.notToggleLabel,s.styles?.notToggleSwitch]);return H.createElement(y.View,{style:r.notToggle,testID:u},H.createElement(y.Text,{style:r.notToggleLabel},o),H.createElement(y.Switch,{style:r.notToggleSwitch,disabled:i,value:e,onValueChange:m=>t(m)}))};var O=c(require("react")),C=require("react-native");var Y=({shiftUp:t,shiftDown:o,shiftUpDisabled:e,shiftDownDisabled:i,disabled:s,labels:u,testID:r,schema:{styles:m}})=>{let R=O.useMemo(()=>({shiftActions:C.StyleSheet.flatten([l.shiftActions,m?.shiftActions])}),[m?.shiftActions]);return O.createElement(C.View,{testID:r,style:R.shiftActions},O.createElement(C.Button,{disabled:s||e,onPress:t,accessibilityLabel:u?.shiftUp,title:u?.shiftUp}),O.createElement(C.Button,{disabled:s||i,onPress:o,accessibilityLabel:u?.shiftDown,title:u?.shiftDown}))};var b=c(require("react")),ce=require("react"),p=require("react-native"),F=require("react-querybuilder");var V=t=>{let{operator:o,value:e,handleOnChange:i,title:s,className:u,type:r="text",inputType:m="text",values:R=[],listsAsArrays:I,fieldData:W,disabled:k,separator:Fe=null,testID:w,selectorComponent:re=t.schema.controls.valueSelector,...S}=t,B=(0,ce.useMemo)(()=>({value:p.StyleSheet.flatten([l.value,S.schema.styles?.value]),valueEditorSwitch:p.StyleSheet.flatten([l.valueEditorSwitch,S.schema.styles?.valueEditorSwitch]),valueList:p.StyleSheet.flatten([l.valueList,S.schema.styles?.valueList])}),[S.schema.styles?.value,S.schema.styles?.valueEditorSwitch,S.schema.styles?.valueList]),{valueAsArray:le,multiValueHandler:ie,parseNumberMethod:Te}=(0,F.useValueEditor)(t);if(o==="null"||o==="notNull")return null;let _=W?.placeholder??"",se=["in","notIn"].includes(o)?"text":m==="number"?"decimal":m??"text";if((o==="between"||o==="notBetween")&&(r==="select"||r==="text")){let N=["from","to"].map((ae,Q)=>r==="text"?b.createElement(p.TextInput,{key:ae,style:B.value,inputMode:se,placeholder:_,value:le[Q]??"",onChangeText:j=>ie(j,Q)}):b.createElement(re,{key:ae,...S,handleOnChange:j=>ie(j,Q),className:u,disabled:k,value:le[Q]??(0,F.getFirstOption)(R),options:R,listsAsArrays:I}));return b.createElement(p.View,{testID:w,style:B.valueList},N[0],Fe,N[1])}switch(r){case"select":case"multiselect":return b.createElement(re,{...S,testID:w,className:u,title:s,handleOnChange:i,disabled:k,value:e,options:R,multiple:r==="multiselect",listsAsArrays:I});case"textarea":return b.createElement(p.TextInput,{testID:w,style:B.value,placeholder:_,value:e,onChangeText:N=>i(N)});case"switch":case"checkbox":return b.createElement(p.Switch,{testID:w,style:B.valueEditorSwitch,disabled:k,value:!!e,onValueChange:N=>i(N)})}return b.createElement(p.TextInput,{testID:w,style:B.value,inputMode:se,placeholder:_,value:e,onChangeText:N=>i((0,F.parseNumber)(N,{parseNumbers:Te}))})};var ve=c(require("react"));var fe=c(require("react"));var de=c(require("react")),ye=require("react"),n=require("react-native"),f=require("react-querybuilder");var v=({handleOnChange:t,options:o,value:e,disabled:i,multiple:s,listsAsArrays:u,schema:r,testID:m})=>{let R=(0,ye.useMemo)(()=>{switch(m){case f.TestID.combinators:return{selector:n.StyleSheet.flatten([l.combinatorSelector,r.styles?.combinatorSelector]),option:n.StyleSheet.flatten([l.combinatorOption,r.styles?.combinatorOption])};case f.TestID.fields:return{selector:n.StyleSheet.flatten([l.fieldSelector,r.styles?.fieldSelector]),option:n.StyleSheet.flatten([l.fieldOption,r.styles?.fieldOption])};case f.TestID.operators:return{selector:n.StyleSheet.flatten([l.operatorSelector,r.styles?.operatorSelector]),option:n.StyleSheet.flatten([l.operatorOption,r.styles?.operatorOption])};case f.TestID.valueSourceSelector:return{selector:n.StyleSheet.flatten([l.valueSourceSelector,r.styles?.valueSourceSelector]),option:n.StyleSheet.flatten([l.valueSourceOption,r.styles?.valueSourceOption])};case f.TestID.valueEditor:return{selector:n.StyleSheet.flatten([l.valueEditorSelector,r.styles?.valueEditorSelector]),option:n.StyleSheet.flatten([l.valueEditorOption,r.styles?.valueEditorOption])};default:}return n.StyleSheet.create(a)},[r.styles?.combinatorOption,r.styles?.combinatorSelector,r.styles?.fieldOption,r.styles?.fieldSelector,r.styles?.operatorOption,r.styles?.operatorSelector,r.styles?.valueEditorOption,r.styles?.valueEditorSelector,r.styles?.valueSourceOption,r.styles?.valueSourceSelector,m]),{onChange:I}=(0,f.useValueSelector)({handleOnChange:t,listsAsArrays:u,multiple:s,value:e}),W=s&&Array.isArray(e)?(0,f.joinWith)(e,","):e;return de.createElement(n.TextInput,{testID:m,"aria-disabled":i,style:R.selector,value:W,onChangeText:I})};var g=t=>fe.createElement(v,{...t});var Z=t=>ve.createElement(V,{...t,selectorComponent:g});var A=c(require("react")),Ge=require("react"),P=require("react-querybuilder"),Oe=require("react-redux");var be=require("react"),J=require("react-querybuilder");var T=c(require("react")),Se=require("react"),h=require("react-native"),x=require("react-querybuilder");var ee=t=>{let o=(0,x.useRuleGroup)(t),e=o.schema,i=(0,Se.useMemo)(()=>({ruleGroup:h.StyleSheet.flatten([l.ruleGroup,e.styles?.ruleGroup]),ruleGroupHeader:h.StyleSheet.flatten([l.ruleGroupHeader,e.styles?.ruleGroupHeader]),ruleGroupBody:h.StyleSheet.flatten([l.ruleGroupBody,e.styles?.ruleGroupBody])}),[e.styles?.ruleGroup,e.styles?.ruleGroupBody,e.styles?.ruleGroupHeader]);return T.createElement(h.View,{style:i.ruleGroup,testID:x.TestID.ruleGroup},T.createElement(h.View,{style:i.ruleGroupHeader},T.createElement(x.RuleGroupHeaderComponents,{...o})),T.createElement(h.View,{style:i.ruleGroupBody},T.createElement(x.RuleGroupBodyComponents,{...o})))};var te=c(require("react")),Ne=require("react"),q=require("react-native"),E=require("react-querybuilder");var oe=t=>{let o=(0,E.useRule)(t),e=o.schema,i=(0,Ne.useMemo)(()=>({rule:q.StyleSheet.flatten([l.rule,e.styles?.rule])}),[e.styles?.rule]);return te.createElement(q.View,{style:i.rule,testID:E.TestID.rule},te.createElement(E.RuleComponents,{...o}))};var X={actionElement:d,addGroupAction:d,addRuleAction:d,cloneGroupAction:d,cloneRuleAction:d,combinatorSelector:v,dragHandle:(0,be.forwardRef)(()=>null),fieldSelector:v,inlineCombinator:z,lockGroupAction:d,lockRuleAction:d,notToggle:K,operatorSelector:v,removeGroupAction:d,removeRuleAction:d,rule:oe,ruleGroup:ee,ruleGroupBodyElements:J.RuleGroupBodyComponents,ruleGroupHeaderElements:J.RuleGroupHeaderComponents,shiftActions:Y,valueEditor:V,valueSelector:v,valueSourceSelector:v},De={...X,combinatorSelector:g,fieldSelector:g,operatorSelector:g,valueEditor:Z,valueSelector:v,valueSourceSelector:g};var ge=require("react"),he=require("react-native"),xe=require("react-querybuilder"),Re=require("react-querybuilder"),Ce=t=>Le(t,(0,xe.useQueryBuilderSetup)(t)),Le=(t,o)=>{let e=(0,Re.useQueryBuilderSchema)(t,o),i=(0,ge.useMemo)(()=>he.StyleSheet.create(t.styles??{}),[t.styles]);return{...e,schema:{...e.schema,styles:i}}};var Me=[],He=({props:t})=>{let o=(0,Ge.useMemo)(()=>({...X,...t.controlElements}),[t.controlElements]),e=Ce({...t,controlElements:o}),{ruleGroup:i}=e.schema.controls;return A.createElement(P.QueryBuilderContext.Provider,{value:e.rqbContext},A.createElement(i,{ruleGroup:e.rootGroup,...e.combinatorPropObject,path:Me,translations:e.translations,schema:e.schema,actions:e.actions,id:e.rootGroup.id,disabled:e.rootGroupDisabled,parentDisabled:e.queryDisabled,context:t.context}))},qe=t=>A.createElement(Oe.Provider,{context:P.QueryBuilderStateContext,store:P.queryBuilderStore},A.createElement(He,{props:t}));0&&(module.exports={NativeActionElement,NativeInlineCombinator,NativeNotToggle,NativeShiftActions,NativeValueEditor,NativeValueEditorWeb,NativeValueSelector,NativeValueSelectorWeb,QueryBuilderNative,RuleGroupNative,RuleNative,defaultNativeControlElements,defaultNativeSelectStyles,defaultNativeStyles,defaultNativeWebControlElements}); | ||
//# sourceMappingURL=react-querybuilder_native.cjs.production.js.map |
@@ -233,109 +233,9 @@ var __defProp = Object.defineProperty; | ||
// src/components/NativeValueEditor.tsx | ||
import * as React6 from "react"; | ||
import { useMemo as useMemo5 } from "react"; | ||
import { StyleSheet as StyleSheet6, Switch as Switch2, TextInput as TextInput2, View as View5 } from "react-native"; | ||
import { getFirstOption, parseNumber, useValueEditor } from "react-querybuilder"; | ||
// src/components/NativeValueSelector.tsx | ||
import * as React5 from "react"; | ||
import { useMemo as useMemo4 } from "react"; | ||
import { StyleSheet as StyleSheet5, TextInput } from "react-native"; | ||
import { TestID as TestID2, joinWith, useValueSelector } from "react-querybuilder"; | ||
var NativeValueSelector = ({ | ||
handleOnChange, | ||
options: _options, | ||
value, | ||
disabled, | ||
multiple, | ||
listsAsArrays, | ||
schema, | ||
testID | ||
}) => { | ||
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j; | ||
const styles = useMemo4(() => { | ||
var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2; | ||
if (testID === TestID2.combinators) { | ||
return { | ||
selector: StyleSheet5.flatten([ | ||
defaultNativeStyles.combinatorSelector, | ||
(_a2 = schema.styles) == null ? void 0 : _a2.combinatorSelector | ||
]), | ||
option: StyleSheet5.flatten([ | ||
defaultNativeStyles.combinatorOption, | ||
(_b2 = schema.styles) == null ? void 0 : _b2.combinatorOption | ||
]) | ||
}; | ||
} else if (testID === TestID2.fields) { | ||
return { | ||
selector: StyleSheet5.flatten([ | ||
defaultNativeStyles.fieldSelector, | ||
(_c2 = schema.styles) == null ? void 0 : _c2.fieldSelector | ||
]), | ||
option: StyleSheet5.flatten([defaultNativeStyles.fieldOption, (_d2 = schema.styles) == null ? void 0 : _d2.fieldOption]) | ||
}; | ||
} else if (testID === TestID2.operators) { | ||
return { | ||
selector: StyleSheet5.flatten([ | ||
defaultNativeStyles.operatorSelector, | ||
(_e2 = schema.styles) == null ? void 0 : _e2.operatorSelector | ||
]), | ||
option: StyleSheet5.flatten([ | ||
defaultNativeStyles.operatorOption, | ||
(_f2 = schema.styles) == null ? void 0 : _f2.operatorOption | ||
]) | ||
}; | ||
} else if (testID === TestID2.valueSourceSelector) { | ||
return { | ||
selector: StyleSheet5.flatten([ | ||
defaultNativeStyles.valueSourceSelector, | ||
(_g2 = schema.styles) == null ? void 0 : _g2.valueSourceSelector | ||
]), | ||
option: StyleSheet5.flatten([ | ||
defaultNativeStyles.valueSourceOption, | ||
(_h2 = schema.styles) == null ? void 0 : _h2.valueSourceOption | ||
]) | ||
}; | ||
} else if (testID === TestID2.valueEditor) { | ||
return { | ||
selector: StyleSheet5.flatten([ | ||
defaultNativeStyles.valueEditorSelector, | ||
(_i2 = schema.styles) == null ? void 0 : _i2.valueEditorSelector | ||
]), | ||
option: StyleSheet5.flatten([ | ||
defaultNativeStyles.valueEditorOption, | ||
(_j2 = schema.styles) == null ? void 0 : _j2.valueEditorOption | ||
]) | ||
}; | ||
} | ||
return StyleSheet5.create(defaultNativeSelectStyles); | ||
}, [ | ||
(_a = schema.styles) == null ? void 0 : _a.combinatorOption, | ||
(_b = schema.styles) == null ? void 0 : _b.combinatorSelector, | ||
(_c = schema.styles) == null ? void 0 : _c.fieldOption, | ||
(_d = schema.styles) == null ? void 0 : _d.fieldSelector, | ||
(_e = schema.styles) == null ? void 0 : _e.operatorOption, | ||
(_f = schema.styles) == null ? void 0 : _f.operatorSelector, | ||
(_g = schema.styles) == null ? void 0 : _g.valueEditorOption, | ||
(_h = schema.styles) == null ? void 0 : _h.valueEditorSelector, | ||
(_i = schema.styles) == null ? void 0 : _i.valueSourceOption, | ||
(_j = schema.styles) == null ? void 0 : _j.valueSourceSelector, | ||
testID | ||
]); | ||
const { onChange } = useValueSelector({ handleOnChange, listsAsArrays, multiple, value }); | ||
const val = multiple ? Array.isArray(value) ? joinWith(value, ",") : value : value; | ||
return /* @__PURE__ */ React5.createElement( | ||
TextInput, | ||
{ | ||
testID, | ||
"aria-disabled": disabled, | ||
style: styles.selector, | ||
value: val, | ||
onChangeText: onChange | ||
} | ||
); | ||
}; | ||
// src/components/NativeValueEditor.tsx | ||
var NativeValueEditor = (_a) => { | ||
var _b = _a, { | ||
import { StyleSheet as StyleSheet5, Switch as Switch2, TextInput, View as View5 } from "react-native"; | ||
import { getFirstOption, parseNumber, useValueEditor } from "react-querybuilder"; | ||
var NativeValueEditor = (allProps) => { | ||
var _b, _c, _d, _e; | ||
const _a = allProps, { | ||
operator, | ||
@@ -350,10 +250,8 @@ value, | ||
listsAsArrays, | ||
parseNumbers, | ||
fieldData, | ||
disabled, | ||
separator = null, | ||
skipHook = false, | ||
testID, | ||
selectorComponent: SelectorComponent = NativeValueSelector | ||
} = _b, props = __objRest(_b, [ | ||
selectorComponent: SelectorComponent = allProps.schema.controls.valueSelector | ||
} = _a, props = __objRest(_a, [ | ||
"operator", | ||
@@ -368,21 +266,18 @@ "value", | ||
"listsAsArrays", | ||
"parseNumbers", | ||
"fieldData", | ||
"disabled", | ||
"separator", | ||
"skipHook", | ||
"testID", | ||
"selectorComponent" | ||
]); | ||
var _a2, _b2, _c, _d; | ||
const styles = useMemo5( | ||
const styles = useMemo4( | ||
() => { | ||
var _a3, _b3, _c2; | ||
var _a2, _b2, _c2; | ||
return { | ||
value: StyleSheet6.flatten([defaultNativeStyles.value, (_a3 = props.schema.styles) == null ? void 0 : _a3.value]), | ||
valueEditorSwitch: StyleSheet6.flatten([ | ||
value: StyleSheet5.flatten([defaultNativeStyles.value, (_a2 = props.schema.styles) == null ? void 0 : _a2.value]), | ||
valueEditorSwitch: StyleSheet5.flatten([ | ||
defaultNativeStyles.valueEditorSwitch, | ||
(_b3 = props.schema.styles) == null ? void 0 : _b3.valueEditorSwitch | ||
(_b2 = props.schema.styles) == null ? void 0 : _b2.valueEditorSwitch | ||
]), | ||
valueList: StyleSheet6.flatten([ | ||
valueList: StyleSheet5.flatten([ | ||
defaultNativeStyles.valueList, | ||
@@ -394,29 +289,19 @@ (_c2 = props.schema.styles) == null ? void 0 : _c2.valueList | ||
[ | ||
(_a2 = props.schema.styles) == null ? void 0 : _a2.value, | ||
(_b2 = props.schema.styles) == null ? void 0 : _b2.valueEditorSwitch, | ||
(_c = props.schema.styles) == null ? void 0 : _c.valueList | ||
(_b = props.schema.styles) == null ? void 0 : _b.value, | ||
(_c = props.schema.styles) == null ? void 0 : _c.valueEditorSwitch, | ||
(_d = props.schema.styles) == null ? void 0 : _d.valueList | ||
] | ||
); | ||
const { valueAsArray, multiValueHandler, parseNumberMethod } = useValueEditor({ | ||
skipHook, | ||
handleOnChange, | ||
inputType, | ||
operator, | ||
value, | ||
type, | ||
listsAsArrays, | ||
parseNumbers, | ||
values | ||
}); | ||
const { valueAsArray, multiValueHandler, parseNumberMethod } = useValueEditor(allProps); | ||
if (operator === "null" || operator === "notNull") { | ||
return null; | ||
} | ||
const placeHolderText = (_d = fieldData == null ? void 0 : fieldData.placeholder) != null ? _d : ""; | ||
const placeHolderText = (_e = fieldData == null ? void 0 : fieldData.placeholder) != null ? _e : ""; | ||
const inputMode = ["in", "notIn"].includes(operator) ? "text" : inputType === "number" ? "decimal" : inputType != null ? inputType : "text"; | ||
if ((operator === "between" || operator === "notBetween") && (type === "select" || type === "text")) { | ||
const editors = ["from", "to"].map((key, i) => { | ||
var _a3, _b3; | ||
var _a2, _b2; | ||
if (type === "text") { | ||
return /* @__PURE__ */ React6.createElement( | ||
TextInput2, | ||
return /* @__PURE__ */ React5.createElement( | ||
TextInput, | ||
{ | ||
@@ -427,3 +312,3 @@ key, | ||
placeholder: placeHolderText, | ||
value: (_a3 = valueAsArray[i]) != null ? _a3 : "", | ||
value: (_a2 = valueAsArray[i]) != null ? _a2 : "", | ||
onChangeText: (v) => multiValueHandler(v, i) | ||
@@ -433,3 +318,3 @@ } | ||
} | ||
return /* @__PURE__ */ React6.createElement( | ||
return /* @__PURE__ */ React5.createElement( | ||
SelectorComponent, | ||
@@ -442,3 +327,3 @@ __spreadProps(__spreadValues({ | ||
disabled, | ||
value: (_b3 = valueAsArray[i]) != null ? _b3 : getFirstOption(values), | ||
value: (_b2 = valueAsArray[i]) != null ? _b2 : getFirstOption(values), | ||
options: values, | ||
@@ -449,3 +334,3 @@ listsAsArrays | ||
}); | ||
return /* @__PURE__ */ React6.createElement(View5, { testID, style: styles.valueList }, editors[0], separator, editors[1]); | ||
return /* @__PURE__ */ React5.createElement(View5, { testID, style: styles.valueList }, editors[0], separator, editors[1]); | ||
} | ||
@@ -455,3 +340,3 @@ switch (type) { | ||
case "multiselect": | ||
return /* @__PURE__ */ React6.createElement( | ||
return /* @__PURE__ */ React5.createElement( | ||
SelectorComponent, | ||
@@ -471,4 +356,4 @@ __spreadProps(__spreadValues({}, props), { | ||
case "textarea": | ||
return /* @__PURE__ */ React6.createElement( | ||
TextInput2, | ||
return /* @__PURE__ */ React5.createElement( | ||
TextInput, | ||
{ | ||
@@ -484,3 +369,3 @@ testID, | ||
case "checkbox": | ||
return /* @__PURE__ */ React6.createElement( | ||
return /* @__PURE__ */ React5.createElement( | ||
Switch2, | ||
@@ -496,4 +381,4 @@ { | ||
} | ||
return /* @__PURE__ */ React6.createElement( | ||
TextInput2, | ||
return /* @__PURE__ */ React5.createElement( | ||
TextInput, | ||
{ | ||
@@ -515,2 +400,110 @@ testID, | ||
import * as React7 from "react"; | ||
// src/components/NativeValueSelector.tsx | ||
import * as React6 from "react"; | ||
import { useMemo as useMemo5 } from "react"; | ||
import { StyleSheet as StyleSheet6, TextInput as TextInput2 } from "react-native"; | ||
import { TestID as TestID2, joinWith, useValueSelector } from "react-querybuilder"; | ||
var NativeValueSelector = ({ | ||
handleOnChange, | ||
options: _options, | ||
value, | ||
disabled, | ||
multiple, | ||
listsAsArrays, | ||
schema, | ||
testID | ||
}) => { | ||
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j; | ||
const styles = useMemo5(() => { | ||
var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2; | ||
switch (testID) { | ||
case TestID2.combinators: { | ||
return { | ||
selector: StyleSheet6.flatten([ | ||
defaultNativeStyles.combinatorSelector, | ||
(_a2 = schema.styles) == null ? void 0 : _a2.combinatorSelector | ||
]), | ||
option: StyleSheet6.flatten([ | ||
defaultNativeStyles.combinatorOption, | ||
(_b2 = schema.styles) == null ? void 0 : _b2.combinatorOption | ||
]) | ||
}; | ||
} | ||
case TestID2.fields: { | ||
return { | ||
selector: StyleSheet6.flatten([ | ||
defaultNativeStyles.fieldSelector, | ||
(_c2 = schema.styles) == null ? void 0 : _c2.fieldSelector | ||
]), | ||
option: StyleSheet6.flatten([defaultNativeStyles.fieldOption, (_d2 = schema.styles) == null ? void 0 : _d2.fieldOption]) | ||
}; | ||
} | ||
case TestID2.operators: { | ||
return { | ||
selector: StyleSheet6.flatten([ | ||
defaultNativeStyles.operatorSelector, | ||
(_e2 = schema.styles) == null ? void 0 : _e2.operatorSelector | ||
]), | ||
option: StyleSheet6.flatten([ | ||
defaultNativeStyles.operatorOption, | ||
(_f2 = schema.styles) == null ? void 0 : _f2.operatorOption | ||
]) | ||
}; | ||
} | ||
case TestID2.valueSourceSelector: { | ||
return { | ||
selector: StyleSheet6.flatten([ | ||
defaultNativeStyles.valueSourceSelector, | ||
(_g2 = schema.styles) == null ? void 0 : _g2.valueSourceSelector | ||
]), | ||
option: StyleSheet6.flatten([ | ||
defaultNativeStyles.valueSourceOption, | ||
(_h2 = schema.styles) == null ? void 0 : _h2.valueSourceOption | ||
]) | ||
}; | ||
} | ||
case TestID2.valueEditor: { | ||
return { | ||
selector: StyleSheet6.flatten([ | ||
defaultNativeStyles.valueEditorSelector, | ||
(_i2 = schema.styles) == null ? void 0 : _i2.valueEditorSelector | ||
]), | ||
option: StyleSheet6.flatten([ | ||
defaultNativeStyles.valueEditorOption, | ||
(_j2 = schema.styles) == null ? void 0 : _j2.valueEditorOption | ||
]) | ||
}; | ||
} | ||
default: | ||
} | ||
return StyleSheet6.create(defaultNativeSelectStyles); | ||
}, [ | ||
(_a = schema.styles) == null ? void 0 : _a.combinatorOption, | ||
(_b = schema.styles) == null ? void 0 : _b.combinatorSelector, | ||
(_c = schema.styles) == null ? void 0 : _c.fieldOption, | ||
(_d = schema.styles) == null ? void 0 : _d.fieldSelector, | ||
(_e = schema.styles) == null ? void 0 : _e.operatorOption, | ||
(_f = schema.styles) == null ? void 0 : _f.operatorSelector, | ||
(_g = schema.styles) == null ? void 0 : _g.valueEditorOption, | ||
(_h = schema.styles) == null ? void 0 : _h.valueEditorSelector, | ||
(_i = schema.styles) == null ? void 0 : _i.valueSourceOption, | ||
(_j = schema.styles) == null ? void 0 : _j.valueSourceSelector, | ||
testID | ||
]); | ||
const { onChange } = useValueSelector({ handleOnChange, listsAsArrays, multiple, value }); | ||
const val = multiple ? Array.isArray(value) ? joinWith(value, ",") : value : value; | ||
return /* @__PURE__ */ React6.createElement( | ||
TextInput2, | ||
{ | ||
testID, | ||
"aria-disabled": disabled, | ||
style: styles.selector, | ||
value: val, | ||
onChangeText: onChange | ||
} | ||
); | ||
}; | ||
// src/components/NativeValueSelectorWeb.tsx | ||
var NativeValueSelectorWeb = (props) => /* @__PURE__ */ React7.createElement(NativeValueSelector, __spreadValues({}, props)); | ||
@@ -517,0 +510,0 @@ |
import * as React from "react"; | ||
import type { ValueEditorNativeProps } from "../types"; | ||
export declare const NativeValueEditor: ({ operator, value, handleOnChange, title, className, type, inputType, values, listsAsArrays, parseNumbers, fieldData, disabled, separator, skipHook, testID, selectorComponent: SelectorComponent,...props }: ValueEditorNativeProps) => React.JSX.Element | null; | ||
export declare const NativeValueEditor: (allProps: ValueEditorNativeProps) => React.JSX.Element | null; |
{ | ||
"name": "@react-querybuilder/native", | ||
"description": "React Native components for react-querybuilder", | ||
"version": "7.7.0-alpha.8", | ||
"version": "7.7.0", | ||
"publishConfig": { | ||
@@ -42,13 +42,13 @@ "access": "public" | ||
"devDependencies": { | ||
"@babel/preset-flow": "^7.24.7", | ||
"@babel/preset-flow": "^7.25.7", | ||
"@testing-library/jest-native": "^5.4.3", | ||
"@testing-library/react-native": "^12.7.2", | ||
"@types/react": "^18.3.9", | ||
"@types/react": "^18.3.11", | ||
"@types/react-test-renderer": "^18.3.0", | ||
"@vitejs/plugin-react-swc": "^3.7.0", | ||
"@vitejs/plugin-react-swc": "^3.7.1", | ||
"react": "^18.3.1", | ||
"react-dom": "^18.3.1", | ||
"react-native": "~0.75.3", | ||
"react-native": "~0.75.4", | ||
"react-native-web": "~0.19.12", | ||
"react-querybuilder": "7.7.0-alpha.8", | ||
"react-querybuilder": "7.7.0", | ||
"react-redux": "^9.1.2", | ||
@@ -62,6 +62,6 @@ "react-test-renderer": "^18.3.1", | ||
"react": ">=18", | ||
"react-querybuilder": "7.7.0-alpha.8", | ||
"react-querybuilder": "7.7.0", | ||
"react-redux": "^9.1.0" | ||
}, | ||
"gitHead": "a5eeb3eae72d03cc8fdb19c81657cd952cad1841" | ||
"gitHead": "3df83ee0fc7031f80802d798a77716fb1c1c364a" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
1
285404
2076