@graphcommerce/ecommerce-ui 1.5.3 → 1.5.5

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/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # @graphcommerce/ecommerce-ui
2
2
 
3
+ ## 1.5.5
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`e76df6dc3`](https://github.com/graphcommerce-org/graphcommerce/commit/e76df6dc37c11c793a5d008ba36932d17dc23855), [`0bd9ea582`](https://github.com/graphcommerce-org/graphcommerce/commit/0bd9ea58230dde79c5fe2cdb07e9860151460270)]:
8
+ - @graphcommerce/next-ui@4.29.0
9
+
10
+ ## 1.5.4
11
+
12
+ ### Patch Changes
13
+
14
+ - [#1655](https://github.com/graphcommerce-org/graphcommerce/pull/1655) [`3dde492ad`](https://github.com/graphcommerce-org/graphcommerce/commit/3dde492ad3a49d96481eeb7453fb305d0017b1a5) Thanks [@FrankHarland](https://github.com/FrankHarland)! - Added Google Analytics support.
15
+
16
+ - Updated dependencies [[`9e630670f`](https://github.com/graphcommerce-org/graphcommerce/commit/9e630670ff6c952ab7b938d890b5509804985cf3), [`cf3518499`](https://github.com/graphcommerce-org/graphcommerce/commit/cf351849999ad6fe73ce2bb258098a7dd301d517), [`2e9fa5984`](https://github.com/graphcommerce-org/graphcommerce/commit/2e9fa5984a07ff14fc1b3a4f62189a26e8e3ecdd), [`adf13069a`](https://github.com/graphcommerce-org/graphcommerce/commit/adf13069af6460c960276b402237371c12fc6dec), [`1b1504c9b`](https://github.com/graphcommerce-org/graphcommerce/commit/1b1504c9b0e51f2787bce91e1ff1940f540411d6), [`8a34f8081`](https://github.com/graphcommerce-org/graphcommerce/commit/8a34f808186274a6fe1d4f309472f1a9c6d00efd)]:
17
+ - @graphcommerce/next-ui@4.28.1
18
+ - @graphcommerce/graphql@3.5.0
19
+
3
20
  ## 1.5.3
4
21
 
5
22
  ### Patch Changes
@@ -7,7 +7,8 @@ type ComposedSubmitButtonProps = ComposedSubmitRenderComponentProps &
7
7
 
8
8
  /** Makes a ComposedSubmitRenderComponent rendered as a LinkOrButton */
9
9
  export const ComposedSubmitButton = forwardRef<HTMLButtonElement, ComposedSubmitButtonProps>(
10
- ({ buttonState, submit, error, children, ...otherProps }, ref) => {
10
+ (props, ref) => {
11
+ const { buttonState, submit, error, children, onClick, ...otherProps } = props
11
12
  const loading =
12
13
  buttonState.isSubmitting || (buttonState.isSubmitSuccessful && !error) ? true : undefined
13
14
 
@@ -20,7 +21,10 @@ export const ComposedSubmitButton = forwardRef<HTMLButtonElement, ComposedSubmit
20
21
  type='submit'
21
22
  {...otherProps}
22
23
  loading={loading}
23
- onClick={submit}
24
+ onClick={(e) => {
25
+ onClick?.(e)
26
+ return submit()
27
+ }}
24
28
  >
25
29
  {children}
26
30
  </Button>
@@ -1,26 +1,18 @@
1
- import {
2
- Control,
3
- Controller,
4
- ControllerProps,
5
- Path,
6
- FieldValues,
7
- } from '@graphcommerce/react-hook-form'
1
+ import { Controller, ControllerProps, FieldValues } from '@graphcommerce/react-hook-form'
8
2
  import { MenuItem, TextField, TextFieldProps } from '@mui/material'
9
3
 
10
4
  export type SelectElementProps<T extends FieldValues> = Omit<
11
5
  TextFieldProps,
12
- 'name' | 'type' | 'onChange'
6
+ 'name' | 'type' | 'onChange' | 'defaultValue'
13
7
  > & {
14
8
  validation?: ControllerProps['rules']
15
- name: Path<T>
16
9
  options?: { id: string | number; label: string | number }[] | any[]
17
10
  valueKey?: string
18
11
  labelKey?: string
19
12
  type?: 'string' | 'number'
20
13
  objectOnChange?: boolean
21
14
  onChange?: (value: any) => void
22
- control?: Control<T>
23
- }
15
+ } & Pick<ControllerProps<T>, 'control' | 'defaultValue' | 'name'>
24
16
 
25
17
  export function SelectElement<TFieldValues extends FieldValues>({
26
18
  name,
@@ -32,6 +24,7 @@ export function SelectElement<TFieldValues extends FieldValues>({
32
24
  objectOnChange,
33
25
  validation = {},
34
26
  control,
27
+ defaultValue,
35
28
  ...rest
36
29
  }: SelectElementProps<TFieldValues>): JSX.Element {
37
30
  const isNativeSelect = !!rest.SelectProps?.native
@@ -46,6 +39,7 @@ export function SelectElement<TFieldValues extends FieldValues>({
46
39
  name={name}
47
40
  rules={validation}
48
41
  control={control}
42
+ defaultValue={defaultValue}
49
43
  render={({ field: { onBlur, onChange, value }, fieldState: { invalid, error } }) => {
50
44
  // handle shrink on number input fields
51
45
  if (type === 'number' && typeof value !== 'undefined') {
@@ -2,7 +2,7 @@ import { QueryResult } from '@graphcommerce/graphql'
2
2
  import React, { startTransition, useEffect, useState } from 'react'
3
3
 
4
4
  export type WaitForQueriesProps = {
5
- waitFor: QueryResult<any, any> | QueryResult<any, any>[] | undefined
5
+ waitFor: QueryResult<any, any> | boolean | (QueryResult<any, any> | boolean)[] | undefined
6
6
  children: React.ReactNode
7
7
  fallback?: React.ReactNode
8
8
  }
@@ -17,9 +17,10 @@ export const WaitForQueries = (props: WaitForQueriesProps) => {
17
17
  useEffect(() => startTransition(() => setMounted(true)), [])
18
18
 
19
19
  // We are done when all queries either have data or an error.
20
- const isDone = (Array.isArray(waitFor) ? waitFor : [waitFor]).every(
21
- (res) => (typeof res === 'undefined' || res.data || res.error || !res.loading) && mounted,
22
- )
20
+ const isDone = (Array.isArray(waitFor) ? waitFor : [waitFor]).every((res) => {
21
+ if (typeof res === 'boolean') return res && mounted
22
+ return (typeof res === 'undefined' || res.data || res.error || !res.loading) && mounted
23
+ })
23
24
 
24
25
  return <>{isDone && mounted ? children : fallback}</>
25
26
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@graphcommerce/ecommerce-ui",
3
3
  "homepage": "https://www.graphcommerce.org/",
4
4
  "repository": "github:graphcommerce-org/graphcommerce",
5
- "version": "1.5.3",
5
+ "version": "1.5.5",
6
6
  "sideEffects": false,
7
7
  "prettier": "@graphcommerce/prettier-config-pwa",
8
8
  "eslintConfig": {
@@ -12,8 +12,8 @@
12
12
  }
13
13
  },
14
14
  "dependencies": {
15
- "@graphcommerce/graphql": "3.4.8",
16
- "@graphcommerce/next-ui": "4.28.0",
15
+ "@graphcommerce/graphql": "3.5.0",
16
+ "@graphcommerce/next-ui": "4.29.0",
17
17
  "@graphcommerce/react-hook-form": "3.3.5",
18
18
  "@mui/icons-material": "^5.10.3",
19
19
  "@mui/x-date-pickers": "^5.0.0",