@webority/mobile-support 0.156.0 → 0.158.0

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.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PhotoTray=void 0;var _mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_labels=require("../labels.js"),_photos=require("../photos.js"),_SupportProvider=require("../SupportProvider.js"),_jsxRuntime=require("react/jsx-runtime");const LABELS={limitNoteOne:"Only {count} more photo fits. The rest were left out.",limitNoteMany:"Only {count} more photos fit. The rest were left out.",remove:"Remove {name}",addPhoto:"Add photo",addPhotoHint:"Add a photo from your library",takePhoto:"Take photo",takePhotoHint:"Take a photo with your camera",alreadyAttached:"{name} is already attached.",addFailed:"That photo could not be added. Try another one."},PhotoTray=({photos:e,onChange:t,remaining:o,maxBytes:i,disabled:a,label:r,allowAdd:l=!0})=>{const s=(0,_SupportProvider.useSupportLabels)("photoTray",LABELS),n=(0,_mobileUi.useTheme)(),c=(0,_react.useMemo)(()=>buildStyles(n),[n]),[u,m]=(0,_react.useState)(null),[d,h]=(0,_react.useState)(null),[b,_]=(0,_react.useState)(null),add=async a=>{h(null),_(null),m(a);try{let r=0;const l=await(0,_photos.pickPhotos)(a,{maxCount:o,maxBytes:i,onTrimmed:e=>{r=e}}),n=l.filter(t=>e.some(e=>e.name===t.name&&e.size===t.size)),c=l.filter(e=>!n.includes(e)),u=[];r>0&&u.push((0,_labels.fillLabel)(1===o?s.limitNoteOne:s.limitNoteMany,{count:o}));const[m]=n;void 0!==m&&u.push((0,_labels.fillLabel)(s.alreadyAttached,{name:m.name})),u.length>0&&_(u.join(" ")),c.length>0&&t([...e,...c])}catch(e){h(e instanceof Error&&"PhotoPermissionError"===e.name?e.message:s.addFailed)}finally{m(null)}},p=o<=0,x=d??b;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:c.root,children:[r?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"label",color:"secondary",children:r}):null,e.length>0&&(0,_jsxRuntime.jsx)(_reactNative.View,{style:c.row,children:e.map((o,i)=>(0,_jsxRuntime.jsxs)(_reactNative.View,{style:c.item,children:[(0,_jsxRuntime.jsx)(_reactNative.Image,{source:{uri:o.uri},style:c.thumb,accessibilityLabel:o.name}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:c.remove,children:(0,_jsxRuntime.jsx)(_mobileUi.IconButton,{size:"sm",variant:"glass",style:c.removeButton,icon:({color:e})=>(0,_jsxRuntime.jsx)(_mobileUi.AppIcon,{name:"trash",color:a?e:n.colors["on-scrim"],size:REMOVE_ICON}),accessibilityLabel:(0,_labels.fillLabel)(s.remove,{name:o.name}),disabled:a,onPress:()=>t(e.filter((e,t)=>t!==i))})})]},`${o.uri}-${i}`))}),l&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:c.actions,children:[(0,_jsxRuntime.jsx)(_mobileUi.Button,{size:"sm",variant:"outline",tone:"neutral",leftIcon:"gallery",label:s.addPhoto,accessibilityLabel:s.addPhotoHint,loading:"library"===u,disabled:a||p||null!==u,onPress:()=>{add("library")}}),(0,_jsxRuntime.jsx)(_mobileUi.Button,{size:"sm",variant:"outline",tone:"neutral",leftIcon:"camera",label:s.takePhoto,accessibilityLabel:s.takePhotoHint,loading:"camera"===u,disabled:a||p||null!==u,onPress:()=>{add("camera")}})]}),x?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"polite",children:x}):null]})};exports.PhotoTray=PhotoTray;const THUMB=72,REMOVE_ICON=16,buildStyles=e=>_reactNative.StyleSheet.create({root:{gap:e.space.xs},row:{flexDirection:"row",flexWrap:"wrap",gap:e.space.xs},item:{width:72,height:72},thumb:{width:72,height:72,borderRadius:e.radius.sm,backgroundColor:e.colors["bg-subtle"]},remove:{position:"absolute",top:e.space.xxs,right:e.space.xxs},removeButton:{borderRadius:e.radius.pill,backgroundColor:e.colors.scrim,borderColor:e.colors["on-scrim"]},actions:{flexDirection:"row",gap:e.space.sm}});
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PhotoTray=void 0;var _mobileUi=require("@webority/mobile-ui"),_react=require("react"),_reactNative=require("react-native"),_labels=require("../labels.js"),_photos=require("../photos.js"),_SupportProvider=require("../SupportProvider.js"),_jsxRuntime=require("react/jsx-runtime");const LABELS={limitNoteOne:"Only {count} more photo fits. The rest were left out.",limitNoteMany:"Only {count} more photos fit. The rest were left out.",remove:"Remove {name}",addPhoto:"Add photo",addPhotoHint:"Add a photo from your library",takePhoto:"Take photo",takePhotoHint:"Take a photo with your camera",alreadyAttached:"{name} is already attached.",addFailed:"That photo could not be added. Try another one."},PhotoTray=({photos:e,onChange:t,remaining:o,maxBytes:i,disabled:a,label:r,allowAdd:l=!0})=>{const s=(0,_SupportProvider.useSupportLabels)("photoTray",LABELS),n=(0,_mobileUi.useTheme)(),c=(0,_react.useMemo)(()=>buildStyles(n),[n]),[u,m]=(0,_react.useState)(null),[d,h]=(0,_react.useState)(null),[b,p]=(0,_react.useState)(null),add=async a=>{h(null),p(null),m(a);try{let r=0;const l=await(0,_photos.pickPhotos)(a,{maxCount:o,maxBytes:i,onTrimmed:e=>{r=e}}),n=l.filter(t=>e.some(e=>e.name===t.name&&e.size===t.size)),c=l.filter(e=>!n.includes(e)),u=[];r>0&&u.push((0,_labels.fillLabel)(1===o?s.limitNoteOne:s.limitNoteMany,{count:o}));const[m]=n;void 0!==m&&u.push((0,_labels.fillLabel)(s.alreadyAttached,{name:m.name})),u.length>0&&p(u.join(" ")),c.length>0&&t([...e,...c])}catch(e){h(e instanceof Error&&"PhotoPermissionError"===e.name?e.message:s.addFailed)}finally{m(null)}},_=o<=0,x=d??b,y=(0,_react.useMemo)(()=>e.map((e,t)=>({key:`${e.uri}-${t}`,photo:e,index:t})),[e]);return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:c.root,children:[r?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"label",color:"secondary",children:r}):null,e.length>0&&(0,_jsxRuntime.jsx)(_reactNative.View,{style:c.row,children:y.map(({key:o,photo:i,index:r})=>(0,_jsxRuntime.jsxs)(_reactNative.View,{style:c.item,children:[(0,_jsxRuntime.jsx)(_reactNative.Image,{source:{uri:i.uri},style:c.thumb,accessibilityLabel:i.name}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:c.remove,children:(0,_jsxRuntime.jsx)(_mobileUi.IconButton,{size:"sm",variant:"glass",style:c.removeButton,icon:({color:e})=>(0,_jsxRuntime.jsx)(_mobileUi.AppIcon,{name:"trash",color:a?e:n.colors["on-scrim"],size:REMOVE_ICON}),accessibilityLabel:(0,_labels.fillLabel)(s.remove,{name:i.name}),disabled:a,onPress:()=>t(e.filter((e,t)=>t!==r))})})]},o))}),l&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:c.actions,children:[(0,_jsxRuntime.jsx)(_mobileUi.Button,{size:"sm",variant:"outline",tone:"neutral",leftIcon:"gallery",label:s.addPhoto,accessibilityLabel:s.addPhotoHint,loading:"library"===u,disabled:a||_||null!==u,onPress:()=>{add("library")}}),(0,_jsxRuntime.jsx)(_mobileUi.Button,{size:"sm",variant:"outline",tone:"neutral",leftIcon:"camera",label:s.takePhoto,accessibilityLabel:s.takePhotoHint,loading:"camera"===u,disabled:a||_||null!==u,onPress:()=>{add("camera")}})]}),x?(0,_jsxRuntime.jsx)(_mobileUi.Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"polite",children:x}):null]})};exports.PhotoTray=PhotoTray;const THUMB=72,REMOVE_ICON=16,buildStyles=e=>_reactNative.StyleSheet.create({root:{gap:e.space.xs},row:{flexDirection:"row",flexWrap:"wrap",gap:e.space.xs},item:{width:72,height:72},thumb:{width:72,height:72,borderRadius:e.radius.sm,backgroundColor:e.colors["bg-subtle"]},remove:{position:"absolute",top:e.space.xxs,right:e.space.xxs},removeButton:{borderRadius:e.radius.pill,backgroundColor:e.colors.scrim,borderColor:e.colors["on-scrim"]},actions:{flexDirection:"row",gap:e.space.sm}});
@@ -1 +1 @@
1
- "use strict";import{AppIcon,Button,IconButton,Text,useTheme}from"@webority/mobile-ui";import{useMemo,useState}from"react";import{Image,StyleSheet,View}from"react-native";import{fillLabel}from"../labels.js";import{pickPhotos}from"../photos.js";import{useSupportLabels}from"../SupportProvider.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const LABELS={limitNoteOne:"Only {count} more photo fits. The rest were left out.",limitNoteMany:"Only {count} more photos fit. The rest were left out.",remove:"Remove {name}",addPhoto:"Add photo",addPhotoHint:"Add a photo from your library",takePhoto:"Take photo",takePhotoHint:"Take a photo with your camera",alreadyAttached:"{name} is already attached.",addFailed:"That photo could not be added. Try another one."};export const PhotoTray=({photos:e,onChange:o,remaining:t,maxBytes:a,disabled:s,label:l,allowAdd:i=!0})=>{const r=useSupportLabels("photoTray",LABELS),n=useTheme(),c=useMemo(()=>buildStyles(n),[n]),[m,d]=useState(null),[u,h]=useState(null),[p,b]=useState(null),add=async s=>{h(null),b(null),d(s);try{let l=0;const i=await pickPhotos(s,{maxCount:t,maxBytes:a,onTrimmed:e=>{l=e}}),n=i.filter(o=>e.some(e=>e.name===o.name&&e.size===o.size)),c=i.filter(e=>!n.includes(e)),m=[];l>0&&m.push(fillLabel(1===t?r.limitNoteOne:r.limitNoteMany,{count:t}));const[d]=n;void 0!==d&&m.push(fillLabel(r.alreadyAttached,{name:d.name})),m.length>0&&b(m.join(" ")),c.length>0&&o([...e,...c])}catch(e){h(e instanceof Error&&"PhotoPermissionError"===e.name?e.message:r.addFailed)}finally{d(null)}},y=t<=0,x=u??p;return _jsxs(View,{style:c.root,children:[l?_jsx(Text,{variant:"label",color:"secondary",children:l}):null,e.length>0&&_jsx(View,{style:c.row,children:e.map((t,a)=>_jsxs(View,{style:c.item,children:[_jsx(Image,{source:{uri:t.uri},style:c.thumb,accessibilityLabel:t.name}),_jsx(View,{style:c.remove,children:_jsx(IconButton,{size:"sm",variant:"glass",style:c.removeButton,icon:({color:e})=>_jsx(AppIcon,{name:"trash",color:s?e:n.colors["on-scrim"],size:REMOVE_ICON}),accessibilityLabel:fillLabel(r.remove,{name:t.name}),disabled:s,onPress:()=>o(e.filter((e,o)=>o!==a))})})]},`${t.uri}-${a}`))}),i&&_jsxs(View,{style:c.actions,children:[_jsx(Button,{size:"sm",variant:"outline",tone:"neutral",leftIcon:"gallery",label:r.addPhoto,accessibilityLabel:r.addPhotoHint,loading:"library"===m,disabled:s||y||null!==m,onPress:()=>{add("library")}}),_jsx(Button,{size:"sm",variant:"outline",tone:"neutral",leftIcon:"camera",label:r.takePhoto,accessibilityLabel:r.takePhotoHint,loading:"camera"===m,disabled:s||y||null!==m,onPress:()=>{add("camera")}})]}),x?_jsx(Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"polite",children:x}):null]})};const THUMB=72,REMOVE_ICON=16,buildStyles=e=>StyleSheet.create({root:{gap:e.space.xs},row:{flexDirection:"row",flexWrap:"wrap",gap:e.space.xs},item:{width:72,height:72},thumb:{width:72,height:72,borderRadius:e.radius.sm,backgroundColor:e.colors["bg-subtle"]},remove:{position:"absolute",top:e.space.xxs,right:e.space.xxs},removeButton:{borderRadius:e.radius.pill,backgroundColor:e.colors.scrim,borderColor:e.colors["on-scrim"]},actions:{flexDirection:"row",gap:e.space.sm}});
1
+ "use strict";import{AppIcon,Button,IconButton,Text,useTheme}from"@webority/mobile-ui";import{useMemo,useState}from"react";import{Image,StyleSheet,View}from"react-native";import{fillLabel}from"../labels.js";import{pickPhotos}from"../photos.js";import{useSupportLabels}from"../SupportProvider.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const LABELS={limitNoteOne:"Only {count} more photo fits. The rest were left out.",limitNoteMany:"Only {count} more photos fit. The rest were left out.",remove:"Remove {name}",addPhoto:"Add photo",addPhotoHint:"Add a photo from your library",takePhoto:"Take photo",takePhotoHint:"Take a photo with your camera",alreadyAttached:"{name} is already attached.",addFailed:"That photo could not be added. Try another one."};export const PhotoTray=({photos:e,onChange:o,remaining:t,maxBytes:a,disabled:s,label:i,allowAdd:l=!0})=>{const r=useSupportLabels("photoTray",LABELS),n=useTheme(),c=useMemo(()=>buildStyles(n),[n]),[m,d]=useState(null),[u,h]=useState(null),[p,b]=useState(null),add=async s=>{h(null),b(null),d(s);try{let i=0;const l=await pickPhotos(s,{maxCount:t,maxBytes:a,onTrimmed:e=>{i=e}}),n=l.filter(o=>e.some(e=>e.name===o.name&&e.size===o.size)),c=l.filter(e=>!n.includes(e)),m=[];i>0&&m.push(fillLabel(1===t?r.limitNoteOne:r.limitNoteMany,{count:t}));const[d]=n;void 0!==d&&m.push(fillLabel(r.alreadyAttached,{name:d.name})),m.length>0&&b(m.join(" ")),c.length>0&&o([...e,...c])}catch(e){h(e instanceof Error&&"PhotoPermissionError"===e.name?e.message:r.addFailed)}finally{d(null)}},y=t<=0,x=u??p,f=useMemo(()=>e.map((e,o)=>({key:`${e.uri}-${o}`,photo:e,index:o})),[e]);return _jsxs(View,{style:c.root,children:[i?_jsx(Text,{variant:"label",color:"secondary",children:i}):null,e.length>0&&_jsx(View,{style:c.row,children:f.map(({key:t,photo:a,index:i})=>_jsxs(View,{style:c.item,children:[_jsx(Image,{source:{uri:a.uri},style:c.thumb,accessibilityLabel:a.name}),_jsx(View,{style:c.remove,children:_jsx(IconButton,{size:"sm",variant:"glass",style:c.removeButton,icon:({color:e})=>_jsx(AppIcon,{name:"trash",color:s?e:n.colors["on-scrim"],size:REMOVE_ICON}),accessibilityLabel:fillLabel(r.remove,{name:a.name}),disabled:s,onPress:()=>o(e.filter((e,o)=>o!==i))})})]},t))}),l&&_jsxs(View,{style:c.actions,children:[_jsx(Button,{size:"sm",variant:"outline",tone:"neutral",leftIcon:"gallery",label:r.addPhoto,accessibilityLabel:r.addPhotoHint,loading:"library"===m,disabled:s||y||null!==m,onPress:()=>{add("library")}}),_jsx(Button,{size:"sm",variant:"outline",tone:"neutral",leftIcon:"camera",label:r.takePhoto,accessibilityLabel:r.takePhotoHint,loading:"camera"===m,disabled:s||y||null!==m,onPress:()=>{add("camera")}})]}),x?_jsx(Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"polite",children:x}):null]})};const THUMB=72,REMOVE_ICON=16,buildStyles=e=>StyleSheet.create({root:{gap:e.space.xs},row:{flexDirection:"row",flexWrap:"wrap",gap:e.space.xs},item:{width:72,height:72},thumb:{width:72,height:72,borderRadius:e.radius.sm,backgroundColor:e.colors["bg-subtle"]},remove:{position:"absolute",top:e.space.xxs,right:e.space.xxs},removeButton:{borderRadius:e.radius.pill,backgroundColor:e.colors.scrim,borderColor:e.colors["on-scrim"]},actions:{flexDirection:"row",gap:e.space.sm}});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webority/mobile-support",
3
- "version": "0.156.0",
3
+ "version": "0.158.0",
4
4
  "description": "Customer support tickets for Webority React Native apps: the support API client, hooks, ticket screens, contact card and a report-an-issue button that attaches a screenshot.",
5
5
  "keywords": [
6
6
  "react-native",
@@ -62,8 +62,8 @@
62
62
  "!**/*.map"
63
63
  ],
64
64
  "peerDependencies": {
65
- "@webority/mobile-core": "0.156.0",
66
- "@webority/mobile-ui": "0.156.0",
65
+ "@webority/mobile-core": "0.158.0",
66
+ "@webority/mobile-ui": "0.158.0",
67
67
  "expo": ">=58.0.0",
68
68
  "expo-file-system": ">=58.0.0",
69
69
  "expo-image-manipulator": ">=58.0.0",
@@ -124,9 +124,9 @@
124
124
  "@react-native/metro-config": "0.88.1",
125
125
  "@testing-library/react-native": "12.9.0",
126
126
  "@types/react": "19.3.0",
127
- "@webority/mobile-core": "0.156.0",
127
+ "@webority/mobile-core": "0.158.0",
128
128
  "@webority/mobile-dev": "0.0.0",
129
- "@webority/mobile-ui": "0.156.0",
129
+ "@webority/mobile-ui": "0.158.0",
130
130
  "expo": "58.0.23",
131
131
  "expo-file-system": "58.0.13",
132
132
  "expo-image-manipulator": "58.0.16",