@tellescope/react-components 1.138.0 → 1.140.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tellescope/react-components",
3
- "version": "1.138.0",
3
+ "version": "1.140.0",
4
4
  "description": "",
5
5
  "main": "./lib/cjs/index.js",
6
6
  "module": "./lib/esm/index.js",
@@ -47,12 +47,12 @@
47
47
  "@reduxjs/toolkit": "^1.6.2",
48
48
  "@stripe/react-stripe-js": "^2.1.0",
49
49
  "@stripe/stripe-js": "^1.52.1",
50
- "@tellescope/constants": "^1.138.0",
51
- "@tellescope/sdk": "^1.138.0",
52
- "@tellescope/types-client": "^1.138.0",
53
- "@tellescope/types-models": "^1.138.0",
50
+ "@tellescope/constants": "^1.140.0",
51
+ "@tellescope/sdk": "^1.140.0",
52
+ "@tellescope/types-client": "^1.140.0",
53
+ "@tellescope/types-models": "^1.140.0",
54
54
  "@tellescope/types-utilities": "^1.69.3",
55
- "@tellescope/utilities": "^1.138.0",
55
+ "@tellescope/utilities": "^1.140.0",
56
56
  "@typescript-eslint/eslint-plugin": "^4.33.0",
57
57
  "@typescript-eslint/parser": "^4.33.0",
58
58
  "css-to-react-native": "^3.0.0",
@@ -79,7 +79,7 @@
79
79
  "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0",
80
80
  "react-native": "^0.65.0 || ^0.66.0 || ^0.67.0 || ^0.68.0 || ^0.71.0"
81
81
  },
82
- "gitHead": "cc023df2e9c137ffc5c2e745a629858b2fe4476b",
82
+ "gitHead": "96366a4b190c7b432fbefd3469f0f9ade17ac589",
83
83
  "publishConfig": {
84
84
  "access": "public"
85
85
  }
@@ -910,6 +910,12 @@ export const useTellescopeForm = ({ form, urlLogicValue, customization, carePlan
910
910
  if (!file.blobs?.length) {
911
911
  return "A file is required"
912
912
  }
913
+ if (typeof field.options?.min === 'number' && file.blobs.length < field.options.min) {
914
+ return `At least ${field.options?.min} file(s) are required`
915
+ }
916
+ if (typeof field.options?.max === 'number' && file.blobs.length > field.options.max) {
917
+ return `At most ${field.options?.max} file(s) are allowed`
918
+ }
913
919
  return null // no need to check against other stuff
914
920
  }
915
921
  // remaining can refer to currentValue, not currentFileValue
package/src/inputs.tsx CHANGED
@@ -348,10 +348,10 @@ export const DeleteWithConfimrationIcon = ({ modelName, color, iconProps, onSucc
348
348
  )
349
349
  }
350
350
 
351
- export const SearchTextInput = ({ onChange, ...props } : TextFieldProps) => (
351
+ export const SearchTextInput = ({ onChange, hideIcon, ...props } : TextFieldProps & { hideIcon?: boolean, }) => (
352
352
  <TextField size="small" placeholder="Search..."
353
353
  onChange={s => onChange?.(s)}
354
- InputProps={{
354
+ InputProps={hideIcon ? undefined : {
355
355
  startAdornment: (
356
356
  <InputAdornment position="start">
357
357
  <SearchIcon color={props.value ? 'primary' : undefined} />
@@ -5,8 +5,8 @@ import { LoadFunction, LoadFunctionArguments } from "@tellescope/sdk"
5
5
  import { ALL_ACCESS, UNSEARCHABLE_FIELDS } from "@tellescope/constants"
6
6
  import { SearchAPIProps, useSearchAPI } from "./hooks"
7
7
  import { TextFieldProps } from "./mui"
8
- import { AppointmentBookingPage, AppointmentLocation, AutomationTrigger, CalendarEventTemplate, CallHoldQueue, ChatRoom, Database, DatabaseRecord, Enduser, FaxLog, File, Form, FormGroup, Forum, Journey, ManagedContentRecord, MessageTemplateSnippet, Organization, PrescriptionRoute, Template, Ticket, TicketQueue, User, UserNotification } from "@tellescope/types-client"
9
- import { Button, Checkbox, Flex, HoverPaper, LoadingButton, LoadingData, LoadingLinear, ScrollingList, SearchTextInput, Typography, useAppointmentBookingPages, useAppointmentLocations, useAutomationTriggers, useCalendarEventTemplates, useCallHoldQueues, useChatRooms, useDatabaseRecords, useDatabases, useEndusers, useFaxLogs, useFiles, useFormGroups, useForms, useForums, useJourneys, useManagedContentRecords, useMessageTemplateSnippets, useNotifications, useOrganization, useOrganizations, usePrescriptionRoutes, useResolvedSession, useSession, useTemplates, useTicketQueues, useTickets, useUsers, value_is_loaded } from "."
8
+ import { AppointmentBookingPage, AppointmentLocation, AutomationTrigger, CalendarEventTemplate, CallHoldQueue, ChatRoom, Database, DatabaseRecord, Enduser, FaxLog, File, Form, FormGroup, Forum, Journey, ManagedContentRecord, MessageTemplateSnippet, Organization, PrescriptionRoute, SuggestedContact, Template, Ticket, TicketQueue, User, UserNotification } from "@tellescope/types-client"
9
+ import { Button, Checkbox, Flex, HoverPaper, LoadingButton, LoadingData, LoadingLinear, ScrollingList, SearchTextInput, Typography, useAppointmentBookingPages, useAppointmentLocations, useAutomationTriggers, useCalendarEventTemplates, useCallHoldQueues, useChatRooms, useDatabaseRecords, useDatabases, useEndusers, useFaxLogs, useFiles, useFormGroups, useForms, useForums, useJourneys, useManagedContentRecords, useMessageTemplateSnippets, useNotifications, useOrganization, useOrganizations, usePrescriptionRoutes, useResolvedSession, useSession, useSuggestedContacts, useTemplates, useTicketQueues, useTickets, useUsers, value_is_loaded } from "."
10
10
  import { SxProps } from "@mui/material"
11
11
  import { AccessPermissions } from "@tellescope/types-models"
12
12
 
@@ -341,6 +341,9 @@ export interface GenericSearchProps <T> extends FilterComponent<T> {
341
341
  attachSearchableFields?: (v: T) => Indexable | undefined,
342
342
  dontFetch?: boolean,
343
343
  autoFocus?: boolean,
344
+ value?: string,
345
+ onChange?: (s: string) => void,
346
+ hideIcon?: boolean,
344
347
  }
345
348
  interface ModelSearchProps<T> extends GenericSearchProps<T>, SearchAPIProps<T> {}
346
349
  export const ModelSearchInput = <T,>({
@@ -352,16 +355,24 @@ export const ModelSearchInput = <T,>({
352
355
  // @ts-ignore remove from props if provided by mistake
353
356
  compoundApiFilter,
354
357
 
358
+ value,
359
+ onChange,
360
+
355
361
  ...props
356
362
  } : ModelSearchProps<T>) => {
357
363
  const cacheKey = `search-cache-${filterKey}`
358
- const [query, setQuery] = useState(read_local_storage(cacheKey) || '')
364
+ const [_query, _setQuery] = useState(read_local_storage(cacheKey) || '')
365
+
366
+ const query = value ?? _query
367
+ const setQuery = onChange ?? _setQuery
359
368
  const filterOnLoadRef = useRef(!!query)
360
369
 
361
370
  useEffect(() => {
362
371
  update_local_storage(cacheKey, query)
363
372
  }, [query])
364
373
 
374
+ useEffect(() => onChange?.(query), [onChange, query])
375
+
365
376
  useSearchAPI({ query, searchAPI, onLoad })
366
377
 
367
378
  useEffect(() => {
@@ -563,6 +574,17 @@ export const FileSearch = (props: Omit<GenericSearchProps<File>, 'filterKey'> &
563
574
  )
564
575
  }
565
576
 
577
+ export const SuggestedContactSearch = (props: Omit<GenericSearchProps<SuggestedContact>, 'filterKey'> & { filterKey?: string }) => {
578
+ const session = useSession()
579
+ const [, { addLocalElements }] = useSuggestedContacts({ dontFetch: true })
580
+ return (
581
+ <ModelSearchInput filterKey="suggested-contact" {...props}
582
+ searchAPI={session.api.suggested_contacts.getSome}
583
+ onLoad={addLocalElements}
584
+ />
585
+ )
586
+ }
587
+
566
588
  export const CallHoldQueueSearch = (props: Omit<GenericSearchProps<CallHoldQueue>, 'filterKey'> & { filterKey?: string }) => {
567
589
  const session = useSession()
568
590
  const [, { addLocalElements }] = useCallHoldQueues({ dontFetch: true })
package/src/state.tsx CHANGED
@@ -92,6 +92,7 @@ import {
92
92
  MessageTemplateSnippet,
93
93
  FaxLog,
94
94
  CallHoldQueue,
95
+ SuggestedContact,
95
96
  } from "@tellescope/types-client"
96
97
 
97
98
  import {
@@ -351,6 +352,7 @@ const formGroupsSlice = createSliceForList<FormGroup, 'form_groups'>('form_group
351
352
  const portalBrandingsSlice = createSliceForList<PortalBranding, 'portal_brandings'>('portal_brandings')
352
353
  const messageTemplateSnippetsSlice = createSliceForList<MessageTemplateSnippet, 'message_template_snippets'>('message_template_snippets')
353
354
  const faxLogsSlice = createSliceForList<FaxLog, 'fax_logs'>('fax_logs')
355
+ const suggestedContactsSlice = createSliceForList<SuggestedContact, 'suggested_contacts'>('suggested_contacts')
354
356
 
355
357
  const roleBasedAccessPermissionsSlice = createSliceForList<RoleBasedAccessPermission, 'role_based_access_permissions'>('role_based_access_permissions')
356
358
 
@@ -437,6 +439,7 @@ export const sharedConfig = {
437
439
  message_template_snippets: messageTemplateSnippetsSlice.reducer,
438
440
  fax_logs: faxLogsSlice.reducer,
439
441
  call_hold_queues: callHoldQueuesSlice.reducer,
442
+ suggested_contacts: suggestedContactsSlice.reducer,
440
443
  },
441
444
  }
442
445
 
@@ -1180,6 +1183,25 @@ export const useUserAndEnduserDisplayInfo = () => {
1180
1183
  return displayInfo
1181
1184
  }
1182
1185
 
1186
+ export const useSuggestedContacts = (options={} as HookOptions<SuggestedContact>) => {
1187
+ const session = useSession()
1188
+
1189
+ return useListStateHook('suggested_contacts', useTypedSelector(s => s.suggested_contacts), session, suggestedContactsSlice,
1190
+ {
1191
+ loadQuery: session.api.suggested_contacts.getSome,
1192
+ findOne: session.api.suggested_contacts.getOne,
1193
+ findByIds: session.api.suggested_contacts.getByIds,
1194
+ addOne: session.api.suggested_contacts.createOne,
1195
+ addSome: session.api.suggested_contacts.createSome,
1196
+ deleteOne: session.api.suggested_contacts.deleteOne,
1197
+ updateOne: session.api.suggested_contacts.updateOne,
1198
+ },
1199
+ {
1200
+ ...options,
1201
+ },
1202
+ )
1203
+ }
1204
+
1183
1205
  export const useFaxLogs = (options={} as HookOptions<FaxLog>) => {
1184
1206
  const session = useSession()
1185
1207