@tellescope/react-components 1.176.0 → 1.178.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.176.0",
3
+ "version": "1.178.0",
4
4
  "description": "",
5
5
  "main": "./lib/cjs/index.js",
6
6
  "module": "./lib/esm/index.js",
@@ -47,13 +47,13 @@
47
47
  "@reduxjs/toolkit": "^1.6.2",
48
48
  "@stripe/react-stripe-js": "^2.9.0",
49
49
  "@stripe/stripe-js": "^1.52.1",
50
- "@tellescope/constants": "^1.176.0",
51
- "@tellescope/sdk": "^1.176.0",
52
- "@tellescope/types-client": "^1.176.0",
53
- "@tellescope/types-models": "^1.176.0",
54
- "@tellescope/types-utilities": "^1.176.0",
55
- "@tellescope/utilities": "^1.176.0",
56
- "@tellescope/validation": "^1.176.0",
50
+ "@tellescope/constants": "^1.178.0",
51
+ "@tellescope/sdk": "^1.178.0",
52
+ "@tellescope/types-client": "^1.178.0",
53
+ "@tellescope/types-models": "^1.178.0",
54
+ "@tellescope/types-utilities": "^1.178.0",
55
+ "@tellescope/utilities": "^1.178.0",
56
+ "@tellescope/validation": "^1.178.0",
57
57
  "@typescript-eslint/eslint-plugin": "^4.33.0",
58
58
  "@typescript-eslint/parser": "^4.33.0",
59
59
  "css-to-react-native": "^3.0.0",
@@ -84,7 +84,7 @@
84
84
  "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0",
85
85
  "react-native": "^0.65.0 || ^0.66.0 || ^0.67.0 || ^0.68.0 || ^0.71.0"
86
86
  },
87
- "gitHead": "0d2bd51eb1418f968d6a11b0376c5e383dbcce34",
87
+ "gitHead": "3a19783254252a6a5f81188049d32b519ad47648",
88
88
  "publishConfig": {
89
89
  "access": "public"
90
90
  }
@@ -46,8 +46,18 @@ export const apply_filters = <T,>(fs: Filters<T>, data: T[]): T[] => {
46
46
  )
47
47
  }
48
48
 
49
- export const useFilters = <T,>(args?: { memoryId?: string, initialFilters?: Filters<T>, reload?: boolean, deserialize?: (fs: Filters<T>) => Filters<T>, onFilterChange?: (fs: Filters<T>) => void }) => {
50
- const { onFilterChange, reload, memoryId, initialFilters, deserialize } = args ?? {}
49
+ export const useFilters = <T,>(
50
+ args?:
51
+ {
52
+ memoryId?: string,
53
+ initialFilters?: Filters<T>,
54
+ reload?: boolean,
55
+ deserialize?: (fs: Filters<T>) => Filters<T>,
56
+ onFilterChange?: (fs: Filters<T>) => void,
57
+ showArchived?: boolean,
58
+ }
59
+ ) => {
60
+ const { onFilterChange, reload, memoryId, initialFilters, deserialize, showArchived, } = args ?? {}
51
61
  if (memoryId && !deserialize) console.warn("memoryId provided without deserialize")
52
62
 
53
63
  const [filters, setFilters] = React.useState<Filters<T>>(
@@ -88,7 +98,13 @@ export const useFilters = <T,>(args?: { memoryId?: string, initialFilters?: Filt
88
98
  onFilterChange(filters)
89
99
  }, [filters, onFilterChange])
90
100
 
91
- const applyFilters = useCallback((data: T[]) => apply_filters(filters, data), [filters])
101
+ const applyFilters = useCallback((
102
+ (data: T[]) => apply_filters(filters, data).filter(v =>
103
+ (showArchived ?? true) ? true : !(v as any).archivedAt
104
+ )
105
+ ),
106
+ [filters, showArchived]
107
+ )
92
108
 
93
109
  const compoundApiFilter = useMemo(() => {
94
110
  let toReturn: LoadFunctionArguments<T> | null = (
@@ -168,6 +184,13 @@ export const record_matches_for_query = <T,>(records: T[], query: string) => {
168
184
  return matches
169
185
  }
170
186
 
187
+ const is_phone_prefix = (s: string) => {
188
+ if (s.length <= 3) return false
189
+
190
+ // has ONLY numbers, (), +, - and spaces
191
+ return /^[ 0-9()+-]+$/.test(s)
192
+ }
193
+
171
194
  export const filter_for_query = <T,>(query: string, getAdditionalFields?: (v: T) => Indexable | undefined): FilterWithData<T> => {
172
195
  const baseFilter = (record: Indexable): number => {
173
196
  if (!record) return 0
@@ -225,13 +248,15 @@ export const filter_for_query = <T,>(query: string, getAdditionalFields?: (v: T)
225
248
  continue
226
249
  }
227
250
  // for phone number search, replace human-readable entries which are not stored
228
- const onlyNumbers = query.replaceAll(/[^0-9]/g, '')
229
- if (
230
- onlyNumbers.length >= 3 &&
231
- value.toUpperCase().includes(onlyNumbers)
232
- ) {
233
- score +=1
234
- continue
251
+ if (is_phone_prefix(query)) {
252
+ const onlyNumbers = query.replaceAll(/[^0-9]/g, '')
253
+ if (
254
+ onlyNumbers.length >= 3 &&
255
+ value.toUpperCase().includes(onlyNumbers)
256
+ ) {
257
+ score +=1
258
+ continue
259
+ }
235
260
  }
236
261
  }
237
262
 
@@ -569,24 +594,11 @@ export const PrescriptionRoutesSearch = (props: Omit<GenericSearchProps<Prescrip
569
594
  export const FaxSearch = (props: Omit<GenericSearchProps<FaxLog>, 'filterKey'> & { filterKey?: string }) => {
570
595
  const session = useSession()
571
596
  const [, { addLocalElements }] = useFaxLogs()
572
- // const [, { findById: findEnduser }] = useEndusers()
573
597
 
574
598
  return (
575
599
  <ModelSearchInput filterKey="fax_logs" {...props}
576
600
  searchAPI={session.api.fax_logs.getSome}
577
601
  onLoad={addLocalElements}
578
- // attachSearchableFields={t => {
579
- // const enduser = t.enduserId ? findEnduser(t.enduserId, { batch: true }) : undefined
580
- // if (!enduser) return undefined
581
-
582
- // const toJoin = {
583
- // fname: enduser.fname,
584
- // lname: enduser.lname,
585
- // fullname: `${enduser.fname} ${enduser.lname}`,
586
- // }
587
-
588
- // return toJoin
589
- // }}
590
602
  />
591
603
  )
592
604
  }