@tellescope/react-components 1.194.0 → 1.196.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.
Files changed (48) hide show
  1. package/lib/cjs/Forms/inputs.d.ts.map +1 -1
  2. package/lib/cjs/Forms/inputs.js +11 -2
  3. package/lib/cjs/Forms/inputs.js.map +1 -1
  4. package/lib/cjs/Forms/wysiwyg.d.ts +2 -1
  5. package/lib/cjs/Forms/wysiwyg.d.ts.map +1 -1
  6. package/lib/cjs/Forms/wysiwyg.js +7 -2
  7. package/lib/cjs/Forms/wysiwyg.js.map +1 -1
  8. package/lib/cjs/state.d.ts.map +1 -1
  9. package/lib/cjs/state.js +6 -0
  10. package/lib/cjs/state.js.map +1 -1
  11. package/lib/cjs/table.d.ts +3 -1
  12. package/lib/cjs/table.d.ts.map +1 -1
  13. package/lib/cjs/table.js +55 -5
  14. package/lib/cjs/table.js.map +1 -1
  15. package/lib/esm/CMS/components.d.ts +0 -1
  16. package/lib/esm/CMS/components.d.ts.map +1 -1
  17. package/lib/esm/Forms/forms.d.ts +3 -3
  18. package/lib/esm/Forms/inputs.d.ts +1 -1
  19. package/lib/esm/Forms/inputs.d.ts.map +1 -1
  20. package/lib/esm/Forms/inputs.js +11 -2
  21. package/lib/esm/Forms/inputs.js.map +1 -1
  22. package/lib/esm/Forms/inputs.native.d.ts +0 -1
  23. package/lib/esm/Forms/inputs.native.d.ts.map +1 -1
  24. package/lib/esm/Forms/wysiwyg.d.ts +2 -1
  25. package/lib/esm/Forms/wysiwyg.d.ts.map +1 -1
  26. package/lib/esm/Forms/wysiwyg.js +7 -2
  27. package/lib/esm/Forms/wysiwyg.js.map +1 -1
  28. package/lib/esm/controls.d.ts +2 -2
  29. package/lib/esm/inputs.d.ts +1 -1
  30. package/lib/esm/inputs.native.d.ts +0 -1
  31. package/lib/esm/inputs.native.d.ts.map +1 -1
  32. package/lib/esm/layout.d.ts +1 -1
  33. package/lib/esm/state.d.ts +288 -288
  34. package/lib/esm/state.d.ts.map +1 -1
  35. package/lib/esm/state.js +6 -0
  36. package/lib/esm/state.js.map +1 -1
  37. package/lib/esm/table.d.ts +3 -1
  38. package/lib/esm/table.d.ts.map +1 -1
  39. package/lib/esm/table.js +55 -5
  40. package/lib/esm/table.js.map +1 -1
  41. package/lib/esm/theme.native.d.ts +0 -1
  42. package/lib/esm/theme.native.d.ts.map +1 -1
  43. package/lib/tsconfig.tsbuildinfo +1 -1
  44. package/package.json +9 -9
  45. package/src/Forms/inputs.tsx +15 -2
  46. package/src/Forms/wysiwyg.tsx +8 -1
  47. package/src/state.tsx +7 -0
  48. package/src/table.tsx +20 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tellescope/react-components",
3
- "version": "1.194.0",
3
+ "version": "1.196.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.194.0",
51
- "@tellescope/sdk": "^1.194.0",
52
- "@tellescope/types-client": "^1.194.0",
53
- "@tellescope/types-models": "^1.194.0",
54
- "@tellescope/types-utilities": "^1.194.0",
55
- "@tellescope/utilities": "^1.194.0",
56
- "@tellescope/validation": "^1.194.0",
50
+ "@tellescope/constants": "^1.196.0",
51
+ "@tellescope/sdk": "^1.196.0",
52
+ "@tellescope/types-client": "^1.196.0",
53
+ "@tellescope/types-models": "^1.196.0",
54
+ "@tellescope/types-utilities": "^1.196.0",
55
+ "@tellescope/utilities": "^1.196.0",
56
+ "@tellescope/validation": "^1.196.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": "aef702a95cf13209de35fc09eb6a628c10db0007",
87
+ "gitHead": "5775521d0ee6a92be5139fb0466772d40ab4d0af",
88
88
  "publishConfig": {
89
89
  "access": "public"
90
90
  }
@@ -1589,6 +1589,7 @@ export const StripeInput = ({ field, value, onChange, setCustomerId }: FormInput
1589
1589
  const [stripePromise, setStripePromise] = useState<ReturnType<typeof loadStripe>>()
1590
1590
  const [, { findById: findProduct }] = useProducts({ dontFetch: true })
1591
1591
  const [answertext, setAnswertext] = useState('')
1592
+ const [error, setError] = useState('')
1592
1593
 
1593
1594
  const fetchRef = useRef(false)
1594
1595
  useEffect(() => {
@@ -1607,7 +1608,12 @@ export const StripeInput = ({ field, value, onChange, setCustomerId }: FormInput
1607
1608
  setBusinessName(businessName)
1608
1609
  setCustomerId(customerId)
1609
1610
  })
1610
- .catch(console.error)
1611
+ .catch((e: any) => {
1612
+ console.error(e)
1613
+ if (typeof e?.message === 'string') {
1614
+ setError(e.message)
1615
+ }
1616
+ })
1611
1617
  }, [session, value, field.id])
1612
1618
 
1613
1619
  const cost = (
@@ -1615,6 +1621,13 @@ export const StripeInput = ({ field, value, onChange, setCustomerId }: FormInput
1615
1621
  .reduce((t, p) => t + (p?.cost?.amount || 0), 0)
1616
1622
  )
1617
1623
 
1624
+ if (error) {
1625
+ return (
1626
+ <Typography color="error">
1627
+ {error}
1628
+ </Typography>
1629
+ )
1630
+ }
1618
1631
  if (value) {
1619
1632
  return (
1620
1633
  <Grid container alignItems="center" wrap="nowrap">
@@ -3384,7 +3397,7 @@ export const ConditionsInput = ({ goToNextField, goToPreviousField, field, value
3384
3397
  }
3385
3398
 
3386
3399
  export const RichTextInput = ({ field, value, onChange }: FormInputProps<'Rich Text'>) => (
3387
- <WYSIWYG initialHTML={value} onChange={v => onChange(v, field.id)} style={{ width: '100%' }} editorStyle={{ width: '100%' }} />
3400
+ <WYSIWYG stopEnterPropagation initialHTML={value} onChange={v => onChange(v, field.id)} style={{ width: '100%' }} editorStyle={{ width: '100%' }} />
3388
3401
  )
3389
3402
 
3390
3403
  export const ChargeebeeInput = ({ field, value, onChange, setCustomerId }: FormInputProps<'Chargebee'> & {
@@ -167,11 +167,12 @@ const getToolbar = ({ hideEmoji } : { hideEmoji?: boolean }) => ({
167
167
 
168
168
 
169
169
 
170
- export const WYSIWYG = ({ updateHtml, initialHTML: _initialHTML='', autoFocus, onChange, style, editorStyle, hideEmoji } : {
170
+ export const WYSIWYG = ({ stopEnterPropagation, updateHtml, initialHTML: _initialHTML='', autoFocus, onChange, style, editorStyle, hideEmoji } : {
171
171
  initialHTML?: string, onChange: (html: string) => void, autoFocus?: boolean,
172
172
  editorStyle?: React.CSSProperties,
173
173
  hideEmoji?: boolean,
174
174
  updateHtml?: string,
175
+ stopEnterPropagation?: boolean,
175
176
  } & Styled) => {
176
177
  const trimmed = _initialHTML.trim()
177
178
  const initialHTML = (
@@ -228,6 +229,12 @@ export const WYSIWYG = ({ updateHtml, initialHTML: _initialHTML='', autoFocus, o
228
229
  editorClassName="demo-editor"
229
230
  onEditorStateChange={setEditorState}
230
231
  toolbar={toolbar}
232
+ handleReturn={e => {
233
+ if (stopEnterPropagation) {
234
+ e.stopPropagation()
235
+ }
236
+ return false // not handled (allow editor to update)
237
+ }}
231
238
  />
232
239
  </Paper>
233
240
  )
package/src/state.tsx CHANGED
@@ -543,6 +543,7 @@ export const lastDataSync = { current : { numResults: 0, at: new Date(0), from:
543
543
  export const useDataSync____internal = () => {
544
544
  const session = useSession()
545
545
  const lastFetch = React.useRef(new Date())
546
+ const lastError = React.useRef(0)
546
547
  const loadTimings = React.useRef({ } as { [index: string]: number })
547
548
  const loaded = React.useRef({ } as { [K in string]?: ClientModelForName[keyof ClientModelForName][] })
548
549
  const deleted = React.useRef({ } as { [K in string]?: string[] })
@@ -596,6 +597,11 @@ export const useDataSync____internal = () => {
596
597
  return
597
598
  }
598
599
 
600
+ // 5 second delay when hitting errors intead of immediate retry
601
+ if (lastError.current > Date.now() - 1000 * 5) {
602
+ return
603
+ }
604
+
599
605
  // ensure we don't miss updates due to latency
600
606
  const from = new Date(lastFetch.current.getTime() - 3000) // large leeway could result in same data being fetched twice, but helps ensure nothing is dropped
601
607
  lastFetch.current = new Date() // update before syncing, not after it returns
@@ -631,6 +637,7 @@ export const useDataSync____internal = () => {
631
637
  .catch(err => {
632
638
  console.error('Sync error', err)
633
639
  lastFetch.current = from // don't skip this interval yet
640
+ lastError.current = Date.now()
634
641
  })
635
642
  }, 1000)
636
643
 
package/src/table.tsx CHANGED
@@ -105,6 +105,8 @@ type LocalFilter = {
105
105
  valuesQualifier?: ListQueryQualifier,
106
106
  }
107
107
 
108
+ const COLUMN_RESIZE_HANDLE_WIDTH = 3
109
+
108
110
  // export type SortType = 'infer'
109
111
  export type Sorting = {
110
112
  field: string,
@@ -358,7 +360,7 @@ export const TableHeader = <T extends Item>({
358
360
  }}
359
361
  >
360
362
  <div style={{
361
- width: '3px',
363
+ width: COLUMN_RESIZE_HANDLE_WIDTH, marginLeft: -COLUMN_RESIZE_HANDLE_WIDTH,
362
364
  height: '30px',
363
365
  backgroundColor: '#22222266',
364
366
  cursor: 'col-resize',
@@ -457,7 +459,7 @@ export const TableRow = <T extends Item>({
457
459
  />
458
460
  </Flex>
459
461
  }
460
- <Flex flex={1} wrap="nowrap">
462
+ <Flex flex={1} wrap="nowrap" style={{ overflow: 'hidden'}}>
461
463
  {fields.map(({ key, width, textAlign='left', render, hidden, style }, i) => hidden ? null : (
462
464
  <Flex key={key} flex={width !== undefined ? 0 : 1} style={{
463
465
  alignItems: 'center',
@@ -497,6 +499,7 @@ export interface PaginationOptions<T> {
497
499
  pageSize?: number;
498
500
  initialPage?: number;
499
501
  pageMemoryId?: string,
502
+ showLoadAll?: boolean,
500
503
  }
501
504
  export interface PaginationProps<T> extends PaginationOptions<T> {
502
505
  items: T[];
@@ -566,6 +569,7 @@ export const usePagination = <T,>({ paginated=true, items, pageMemoryId, pageSiz
566
569
 
567
570
  export interface TableFooterProps <T> extends Styled, HorizontalPadded, Partial<LoadMoreFunctions<T>>, ReturnType<typeof usePagination> {
568
571
  loadMoreOptions?: LoadMoreOptions<T>,
572
+ showLoadAll?: boolean,
569
573
  }
570
574
  export const TableFooter = <T,>({ horizontalPadding, style, previousDisabled, nextDisabled, selectedPage, numPages, goToNext, goToPrevious } : TableFooterProps<T>) => {
571
575
  return (
@@ -606,7 +610,7 @@ const resolve_middle_page_numbers = (selectedPage: number, numPages: number): [u
606
610
  }
607
611
 
608
612
  const FOOTER_BUTTON_SIZE = 30
609
- export const TableFooterNumbered = <T,>({ horizontalPadding, loadMore, loadMoreOptions, doneLoading, style, previousDisabled, nextDisabled, selectedPage, numPages, goToNext, goToPrevious, goToPage } : TableFooterProps<T>) => {
613
+ export const TableFooterNumbered = <T,>({ showLoadAll, horizontalPadding, loadMore, loadMoreOptions, doneLoading, style, previousDisabled, nextDisabled, selectedPage, numPages, goToNext, goToPrevious, goToPage } : TableFooterProps<T>) => {
610
614
  const [middleLeft, middle, middleRight] = resolve_middle_page_numbers(selectedPage, numPages)
611
615
 
612
616
  const buttonProps = {
@@ -677,6 +681,18 @@ export const TableFooterNumbered = <T,>({ horizontalPadding, loadMore, loadMoreO
677
681
  <NavigateNextIcon/>
678
682
  </Button>
679
683
 
684
+ {showLoadAll &&
685
+ <LoadingButton variant="outlined" submitText="Load All" submittingText="Loading..."
686
+ style={{ width: 175, height: 32, marginLeft: 5 }}
687
+ disabled={doneLoading?.()}
688
+ onClick={async () => {
689
+ while (!doneLoading?.()) {
690
+ await loadMore?.(loadMoreOptions)
691
+ }
692
+ }}
693
+ />
694
+ }
695
+
680
696
 
681
697
  <Typography style={{ fontSize: 12, marginLeft: 'auto' }}>
682
698
  Page {selectedPage + 1} of {numPages}
@@ -1143,7 +1159,7 @@ export const Table = <T extends Item>({
1143
1159
  } />
1144
1160
 
1145
1161
  {paginated && FooterComponent && items.length > 0 && // avoid displaying footer / unnecessary border when no items
1146
- <FooterComponent doneLoading={doneLoading} loadMore={loadMore} loadMoreOptions={loadMoreOptions} {...paginationProps } {...pageOptions} horizontalPadding={horizontalPadding}/>
1162
+ <FooterComponent showLoadAll={pageOptions.showLoadAll} doneLoading={doneLoading} loadMore={loadMore} loadMoreOptions={loadMoreOptions} {...paginationProps } {...pageOptions} horizontalPadding={horizontalPadding}/>
1147
1163
  }
1148
1164
  </Flex>
1149
1165
  )