UNPKG

one

Version:

One is a React framework for web, iOS, and Android apps.

1 lines • 2.73 kB
{"version":3,"file":"StackScreen.js","names":[],"sources":["esm/layouts/stack-utils/StackScreen.js"],"sourcesContent":["\"use client\";\n\nimport { Children, isValidElement, useMemo } from \"react\";\nimport { NAVIGATOR_CONFIG } from \"../../headless/children\";\nimport { StackHeaderComponent, appendStackHeaderPropsToOptions } from \"./StackHeaderComponent\";\nimport { StackToolbarComponent, appendStackToolbarPropsToOptions } from \"./StackToolbar\";\nimport { Screen } from \"../../views/Screen\";\nimport { jsx } from \"react/jsx-runtime\";\n\nfunction StackScreen({ children, options, ...rest }) {\n\tconst updatedOptions = useMemo(() => appendScreenStackPropsToOptions(options ?? {}, { children }), [options, children]);\n\treturn /* @__PURE__ */ jsx(Screen, {\n\t\t...rest,\n\t\toptions: updatedOptions\n\t});\n}\nObject.assign(StackScreen, { [NAVIGATOR_CONFIG]: true });\nfunction validateStackPresentation(options) {\n\tif (typeof options === \"function\") return (...args) => {\n\t\treturn validateStackPresentation(options(...args));\n\t};\n\treturn options;\n}\nfunction appendScreenStackPropsToOptions(options, props) {\n\tlet updatedOptions = {\n\t\t...options,\n\t\t...props.options\n\t};\n\tupdatedOptions = validateStackPresentation(updatedOptions);\n\tfunction appendChildOptions(child, options2) {\n\t\tif (child.type === StackHeaderComponent) return appendStackHeaderPropsToOptions(options2, child.props);\n\t\telse if (child.type === StackToolbarComponent) return appendStackToolbarPropsToOptions(options2, child.props);\n\t\telse console.warn(`Warning: Unknown child element passed to Stack.Screen: ${child.type.name ?? child.type}`);\n\t\treturn options2;\n\t}\n\tChildren.forEach(props.children, (child) => {\n\t\tif (isValidElement(child)) updatedOptions = appendChildOptions(child, updatedOptions);\n\t});\n\treturn updatedOptions;\n}\n\nexport { StackScreen, appendScreenStackPropsToOptions, validateStackPresentation };"],"mappings":";;;;;;;;;;AASA,SAAS,YAAY,EAAE,UAAU,SAAS,GAAG,QAAQ;CACpD,MAAM,iBAAiB,cAAc,gCAAgC,WAAW,CAAC,GAAG,EAAE,SAAS,CAAC,GAAG,CAAC,SAAS,QAAQ,CAAC;CACtH,OAAuB,oBAAI,QAAQ;EAClC,GAAG;EACH,SAAS;CACV,CAAC;AACF;AACA,OAAO,OAAO,aAAa,GAAG,mBAAmB,KAAK,CAAC;AACvD,SAAS,0BAA0B,SAAS;CAC3C,IAAI,OAAO,YAAY,YAAY,QAAQ,GAAG,SAAS;EACtD,OAAO,0BAA0B,QAAQ,GAAG,IAAI,CAAC;CAClD;CACA,OAAO;AACR;AACA,SAAS,gCAAgC,SAAS,OAAO;CACxD,IAAI,iBAAiB;EACpB,GAAG;EACH,GAAG,MAAM;CACV;CACA,iBAAiB,0BAA0B,cAAc;CACzD,SAAS,mBAAmB,OAAO,UAAU;EAC5C,IAAI,MAAM,SAAS,sBAAsB,OAAO,gCAAgC,UAAU,MAAM,KAAK;OAChG,IAAI,MAAM,SAAS,uBAAuB,OAAO,iCAAiC,UAAU,MAAM,KAAK;OACvG,QAAQ,KAAK,0DAA0D,MAAM,KAAK,QAAQ,MAAM,MAAM;EAC3G,OAAO;CACR;CACA,SAAS,QAAQ,MAAM,WAAW,UAAU;EAC3C,IAAI,eAAe,KAAK,GAAG,iBAAiB,mBAAmB,OAAO,cAAc;CACrF,CAAC;CACD,OAAO;AACR"}