@graphcommerce/next-ui 8.0.6-canary.0 → 8.0.6-canary.2

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.
@@ -1,5 +1,10 @@
1
1
  /* eslint-disable import/no-extraneous-dependencies */
2
- import { Controller, ControllerProps, FieldValues } from '@graphcommerce/react-hook-form'
2
+ import {
3
+ Controller,
4
+ ControllerProps,
5
+ FieldValues,
6
+ useController,
7
+ } from '@graphcommerce/react-hook-form'
3
8
  import React, { MouseEventHandler } from 'react'
4
9
  import { ActionCardProps } from './ActionCard'
5
10
  import { ActionCardList, ActionCardListProps } from './ActionCardList'
@@ -43,38 +48,41 @@ export function ActionCardListForm<
43
48
  : selectValues === itemValue
44
49
  }
45
50
 
51
+ const {
52
+ field: { onChange, value, ref },
53
+ fieldState,
54
+ formState,
55
+ } = useController({
56
+ ...props,
57
+ control,
58
+ name,
59
+ defaultValue,
60
+ rules: { required: errorMessage || required, ...rules },
61
+ })
62
+
46
63
  return (
47
- <Controller
48
- {...props}
49
- control={control}
50
- name={name}
51
- defaultValue={defaultValue}
52
- rules={{ required: errorMessage || required, ...rules }}
53
- render={({ field: { onChange, value, ref }, fieldState, formState }) => (
54
- <ActionCardList
55
- {...other}
56
- multiple={multiple}
57
- required={required}
58
- value={value}
59
- ref={ref}
60
- onChange={(_, incomming) => onChange(incomming)}
61
- error={formState.isSubmitted && !!fieldState.error}
62
- errorMessage={fieldState.error?.message}
63
- >
64
- {items.map((item) => (
65
- <RenderItem
66
- {...item}
67
- key={item.value ?? ''}
68
- value={item.value}
69
- selected={onSelect(item.value, value)}
70
- onReset={(e) => {
71
- e.preventDefault()
72
- onChange(null)
73
- }}
74
- />
75
- ))}
76
- </ActionCardList>
77
- )}
78
- />
64
+ <ActionCardList
65
+ {...other}
66
+ multiple={multiple}
67
+ required={required}
68
+ value={value}
69
+ ref={ref}
70
+ onChange={(_, incomming) => onChange(incomming)}
71
+ error={formState.isSubmitted && !!fieldState.error}
72
+ errorMessage={fieldState.error?.message}
73
+ >
74
+ {items.map((item) => (
75
+ <RenderItem
76
+ {...item}
77
+ key={item.value ?? ''}
78
+ value={item.value}
79
+ selected={onSelect(item.value, value)}
80
+ onReset={(e) => {
81
+ e.preventDefault()
82
+ onChange(null)
83
+ }}
84
+ />
85
+ ))}
86
+ </ActionCardList>
79
87
  )
80
88
  }
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Change Log
2
2
 
3
+ ## 8.0.6-canary.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#2234](https://github.com/graphcommerce-org/graphcommerce/pull/2234) [`43bd04a`](https://github.com/graphcommerce-org/graphcommerce/commit/43bd04a777c5800cc7e01bee1e123a5aad82f194) - Added useIsSSR hook that will properly resolve when the page is rendered on the server and on first render, but will return false when a component is rendered on the client directly.
8
+ ([@FrankHarland](https://github.com/FrankHarland))
9
+
10
+ - [#2234](https://github.com/graphcommerce-org/graphcommerce/pull/2234) [`0767bc4`](https://github.com/graphcommerce-org/graphcommerce/commit/0767bc40f7b596209f24ca4e745ff0441f3275c9) - Upgrade input components to no longer use muiRegister, which improves INP scores
11
+ ([@FrankHarland](https://github.com/FrankHarland))
12
+
13
+ ## 8.0.6-canary.1
14
+
3
15
  ## 8.0.6-canary.0
4
16
 
5
17
  ### Patch Changes
package/hooks/index.ts CHANGED
@@ -5,4 +5,5 @@ export * from './useNumberFormat'
5
5
  export * from './useMemoObject'
6
6
  export * from './useStorefrontConfig'
7
7
  export * from './useUrlQuery'
8
+ export * from './useSsr'
8
9
  export * from './useLocale'
@@ -0,0 +1,11 @@
1
+ import { useSyncExternalStore } from 'react'
2
+
3
+ const emptySubscribe = () => () => {}
4
+
5
+ export function useIsSSR() {
6
+ return useSyncExternalStore(
7
+ emptySubscribe,
8
+ () => false,
9
+ () => true,
10
+ )
11
+ }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@graphcommerce/next-ui",
3
3
  "homepage": "https://www.graphcommerce.org/",
4
4
  "repository": "github:graphcommerce-org/graphcommerce",
5
- "version": "8.0.6-canary.0",
5
+ "version": "8.0.6-canary.2",
6
6
  "sideEffects": false,
7
7
  "prettier": "@graphcommerce/prettier-config-pwa",
8
8
  "eslintConfig": {
@@ -25,14 +25,14 @@
25
25
  "typescript": "5.3.3"
26
26
  },
27
27
  "peerDependencies": {
28
- "@graphcommerce/eslint-config-pwa": "^8.0.6-canary.0",
29
- "@graphcommerce/framer-next-pages": "^8.0.6-canary.0",
30
- "@graphcommerce/framer-scroller": "^8.0.6-canary.0",
31
- "@graphcommerce/framer-utils": "^8.0.6-canary.0",
32
- "@graphcommerce/image": "^8.0.6-canary.0",
33
- "@graphcommerce/lingui-next": "^8.0.6-canary.0",
34
- "@graphcommerce/prettier-config-pwa": "^8.0.6-canary.0",
35
- "@graphcommerce/typescript-config-pwa": "^8.0.6-canary.0",
28
+ "@graphcommerce/eslint-config-pwa": "^8.0.6-canary.2",
29
+ "@graphcommerce/framer-next-pages": "^8.0.6-canary.2",
30
+ "@graphcommerce/framer-scroller": "^8.0.6-canary.2",
31
+ "@graphcommerce/framer-utils": "^8.0.6-canary.2",
32
+ "@graphcommerce/image": "^8.0.6-canary.2",
33
+ "@graphcommerce/lingui-next": "^8.0.6-canary.2",
34
+ "@graphcommerce/prettier-config-pwa": "^8.0.6-canary.2",
35
+ "@graphcommerce/typescript-config-pwa": "^8.0.6-canary.2",
36
36
  "@lingui/core": "^4.2.1",
37
37
  "@lingui/macro": "^4.2.1",
38
38
  "@lingui/react": "^4.2.1",