nitro-web 0.0.107 → 0.0.108

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.
@@ -4,9 +4,10 @@ import { Errors } from 'nitro-web/types'
4
4
  type resetInstructionsProps = {
5
5
  className?: string,
6
6
  elements?: { Button?: typeof Button },
7
+ redirectTo?: string,
7
8
  }
8
9
 
9
- export function ResetInstructions({ className, elements }: resetInstructionsProps) {
10
+ export function ResetInstructions({ className, elements, redirectTo }: resetInstructionsProps) {
10
11
  const navigate = useNavigate()
11
12
  const isLoading = useState(false)
12
13
  const [, setStore] = useTracked()
@@ -20,7 +21,7 @@ export function ResetInstructions({ className, elements }: resetInstructionsProp
20
21
  try {
21
22
  await request('post /api/reset-instructions', state, event, isLoading, setState)
22
23
  setStore((s) => ({ ...s, message: 'Done! Please check your email.' }))
23
- navigate('/signin')
24
+ navigate(redirectTo || '/signin')
24
25
  } catch (e) {
25
26
  return setState({ ...state, errors: e as Errors })
26
27
  }
@@ -47,7 +48,7 @@ export function ResetInstructions({ className, elements }: resetInstructionsProp
47
48
  )
48
49
  }
49
50
 
50
- export function ResetPassword({ className, elements }: resetInstructionsProps) {
51
+ export function ResetPassword({ className, elements, redirectTo }: resetInstructionsProps) {
51
52
  const navigate = useNavigate()
52
53
  const params = useParams()
53
54
  const isLoading = useState(false)
@@ -67,7 +68,7 @@ export function ResetPassword({ className, elements }: resetInstructionsProps) {
67
68
  try {
68
69
  const data = await request('post /api/reset-password', state, event, isLoading, setState)
69
70
  setStore((s) => ({ ...s, ...data }))
70
- navigate('/')
71
+ navigate(redirectTo || '/')
71
72
  } catch (e) {
72
73
  return setState({ ...state, errors: e as Errors })
73
74
  }
@@ -4,9 +4,10 @@ import { Errors } from 'nitro-web/types'
4
4
  type signinProps = {
5
5
  className?: string,
6
6
  elements?: { Button?: typeof Button },
7
+ redirectTo?: string,
7
8
  }
8
9
 
9
- export function Signin({ className, elements }: signinProps) {
10
+ export function Signin({ className, elements, redirectTo }: signinProps) {
10
11
  const navigate = useNavigate()
11
12
  const location = useLocation()
12
13
  const isSignout = location.pathname == '/signout'
@@ -48,7 +49,7 @@ export function Signin({ className, elements }: signinProps) {
48
49
  setStore((s) => ({ ...s, ...data }))
49
50
  setTimeout(() => { // wait for setStore
50
51
  if (location.search.includes('redirect')) navigate(location.search.replace('?redirect=', ''))
51
- else navigate('/')
52
+ else navigate(redirectTo || '/')
52
53
  }, 100)
53
54
  } catch (e) {
54
55
  return setState({ ...state, errors: e as Errors})
@@ -4,9 +4,10 @@ import { Errors } from 'nitro-web/types'
4
4
  type signupProps = {
5
5
  className?: string,
6
6
  elements?: { Button?: typeof Button },
7
+ redirectTo?: string,
7
8
  }
8
9
 
9
- export function Signup({ className, elements }: signupProps) {
10
+ export function Signup({ className, elements, redirectTo }: signupProps) {
10
11
  const navigate = useNavigate()
11
12
  const isLoading = useState(false)
12
13
  const [, setStore] = useTracked()
@@ -26,7 +27,7 @@ export function Signup({ className, elements }: signupProps) {
26
27
  try {
27
28
  const data = await request('post /api/signup', state, e, isLoading, setState)
28
29
  setStore((prev) => ({ ...prev, ...data }))
29
- setTimeout(() => navigate('/'), 0) // wait for setStore
30
+ setTimeout(() => navigate(redirectTo || '/'), 0) // wait for setStore
30
31
  } catch (e) {
31
32
  setState((prev) => ({ ...prev, errors: e as Errors }))
32
33
  }
@@ -100,8 +100,8 @@ export function Table<T extends TableRow>({
100
100
  else return align == 'left' ? '' : align == 'center' ? 'text-center' : 'text-right'
101
101
  }, [])
102
102
 
103
- // Reset selected rows when the location changes
104
- useEffect(() => setSelectedRowIds([]), [location.key])
103
+ // Reset selected rows when the location changes, or the number of rows changed (e.g. when a row is removed)
104
+ useEffect(() => setSelectedRowIds([]), [location.key, rows.map(row => row?._id||'').join(',')])
105
105
 
106
106
  // --- Sorting ---
107
107
 
@@ -134,7 +134,8 @@ export function Table<T extends TableRow>({
134
134
  columns.map((col, j) => {
135
135
  const disableSort = col.disableSort || selectedRowIds.length
136
136
  const sideColor = j == 0 && rowSideColor ? rowSideColor(undefined) : undefined
137
- const pl = j == 0 ? columnPaddingX : columnGap
137
+ const sideColorPadding = sideColor && rows.length > 0 ? sideColor.width + 5 : 0
138
+ const pl = sideColorPadding + (j == 0 ? columnPaddingX : columnGap)
138
139
  const pr = j == columns.length - 1 ? columnPaddingX : columnGap
139
140
  return (
140
141
  <div
@@ -152,13 +153,10 @@ export function Table<T extends TableRow>({
152
153
  )}
153
154
  >
154
155
  <div
155
- style={{
156
- maxHeight: rowContentHeightMax,
157
- paddingLeft: sideColor && rows.length > 0 ? sideColor.width + 5 : 0,
158
- }}
156
+ style={{ maxHeight: rowContentHeightMax }}
159
157
  className={twMerge(
158
+ col.value == 'checkbox' ? 'relative' : getLineClampClassName(col.rowLinesMax),
160
159
  rowContentHeightMax ? 'overflow-hidden' : '',
161
- getLineClampClassName(col.rowLinesMax),
162
160
  col.overflow ? 'overflow-visible' : '',
163
161
  col.innerClassName
164
162
  )}
@@ -175,7 +173,7 @@ export function Table<T extends TableRow>({
175
173
  onChange={(e) => onSelect('all', e.target.checked)}
176
174
  />
177
175
  <div
178
- className={`${selectedRowIds.length ? 'block' : 'hidden'} [&>*]:absolute [&>*]:inset-y-0 [&>*]:left-[68px] [&>*]:z-10`}
176
+ className={`${selectedRowIds.length ? 'block' : 'hidden'} [&>*]:absolute [&>*]:inset-y-0 [&>*]:left-[35px] [&>*]:z-10 whitespace-nowrap`}
179
177
  >
180
178
  {generateCheckboxActions && generateCheckboxActions(selectedRowIds)}
181
179
  </div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nitro-web",
3
- "version": "0.0.107",
3
+ "version": "0.0.108",
4
4
  "repository": "github:boycce/nitro-web",
5
5
  "homepage": "https://boycce.github.io/nitro-web/",
6
6
  "description": "Nitro is a battle-tested, modular base project to turbocharge your projects, styled using Tailwind 🚀",
package/types/util.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Returns an address monastery schema which Google autocomplete should return
2
+ * Returns a monastery schema which matches the Google autocomplete output
3
3
  */
4
4
  export function addressSchema(): {
5
5
  city: {
package/types.ts CHANGED
@@ -59,6 +59,24 @@ export type Store = {
59
59
  user?: User,
60
60
  }
61
61
 
62
+ // util.addressSchema
63
+ export type Address = {
64
+ city?: string
65
+ country?: string
66
+ full?: string
67
+ line1?: string
68
+ line2?: string
69
+ number?: string
70
+ postcode?: string
71
+ suburb?: string
72
+ unit?: string
73
+ area?: {
74
+ bottomLeft?: [number, number]
75
+ topRight?: [number, number]
76
+ }
77
+ location?: [number, number]
78
+ }
79
+
62
80
  export type Svg = React.FC<React.SVGProps<SVGElement>>
63
81
 
64
82
  /*
package/util.js CHANGED
@@ -35,7 +35,7 @@ let scrollbarCache
35
35
  let axiosNonce
36
36
 
37
37
  /**
38
- * Returns an address monastery schema which Google autocomplete should return
38
+ * Returns a monastery schema which matches the Google autocomplete output
39
39
  */
40
40
  export function addressSchema () {
41
41
  // Google autocomplete should return the following object