@graphcommerce/next-ui 7.0.0-canary.21 → 7.0.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.
@@ -1,7 +1,7 @@
1
1
  import { spreadLinear, spreadVal } from '../spreadVal'
2
2
 
3
3
  it('generates the right spreadVal', () => {
4
- const s = (val: any) => JSON.stringify(val)
4
+ const s = (val: unknown) => JSON.stringify(val)
5
5
 
6
6
  expect(s(spreadLinear(15, 18, 'xl'))).toMatchInlineSnapshot(`"[15,15.53,16.2,17.28,18]"`)
7
7
  expect(s(spreadLinear(15, 18))).toMatchInlineSnapshot(`"[15,16.31,18,18,18]"`)
@@ -1,12 +1,14 @@
1
1
  import { i18n } from '@lingui/core'
2
2
  import {
3
- IconButton,
4
3
  IconButtonProps,
5
4
  SxProps,
5
+ Box,
6
+ // eslint-disable-next-line @typescript-eslint/no-restricted-imports
6
7
  TextField,
7
8
  TextFieldProps,
8
9
  useForkRef,
9
10
  Theme,
11
+ Fab,
10
12
  } from '@mui/material'
11
13
  import { ChangeEvent, Ref, useCallback, useEffect, useRef, useState } from 'react'
12
14
  import { IconSvg } from '../IconSvg'
@@ -36,6 +38,7 @@ export function TextInputNumber(props: TextInputNumberProps) {
36
38
  UpProps = {},
37
39
  inputProps = {},
38
40
  inputRef,
41
+ variant = 'outlined',
39
42
  sx = [],
40
43
  ...textFieldProps
41
44
  } = props
@@ -91,11 +94,27 @@ export function TextInputNumber(props: TextInputNumberProps) {
91
94
  <TextField
92
95
  {...textFieldProps}
93
96
  type='number'
97
+ variant={variant}
94
98
  inputRef={forkRef}
95
99
  className={`${textFieldProps.className ?? ''} ${classes.quantity}`}
96
100
  sx={[
97
101
  {
98
- width: responsiveVal(80, 120),
102
+ width: responsiveVal(90, 120),
103
+ },
104
+ {
105
+ '& .MuiOutlinedInput-root': {
106
+ px: '3px',
107
+ display: 'grid',
108
+ gridTemplateColumns: '1fr auto 1fr',
109
+ },
110
+ },
111
+ variant === 'standard' && {
112
+ '& .MuiOutlinedInput-input': {
113
+ padding: 0,
114
+ },
115
+ '& .MuiOutlinedInput-notchedOutline': {
116
+ display: 'none',
117
+ },
99
118
  },
100
119
  ...(Array.isArray(sx) ? sx : [sx]),
101
120
  ]}
@@ -103,36 +122,36 @@ export function TextInputNumber(props: TextInputNumberProps) {
103
122
  InputProps={{
104
123
  ...textFieldProps.InputProps,
105
124
  startAdornment: (
106
- <IconButton
107
- aria-label={i18n._(/* i18n */ 'Decrease')}
108
- size='medium'
109
- edge='start'
110
- onPointerDown={() => setDirection('down')}
111
- onPointerUp={stop}
112
- // disabled={textFieldProps.disabled || disabled === 'min'}
113
- tabIndex={-1}
114
- color='inherit'
115
- {...DownProps}
116
- className={`${classes.button} ${DownProps.className ?? ''}`}
117
- >
118
- {DownProps.children ?? <IconSvg src={iconMin} size='small' />}
119
- </IconButton>
125
+ <Box>
126
+ <Fab
127
+ aria-label={i18n._(/* i18n */ 'Decrease')}
128
+ size='smaller'
129
+ sx={{ boxShadow: variant === 'standard' ? 4 : 0, minHeight: '30px' }}
130
+ onPointerDown={() => setDirection('down')}
131
+ onPointerUp={stop}
132
+ tabIndex={-1}
133
+ {...DownProps}
134
+ className={`${classes.button} ${DownProps.className ?? ''}`}
135
+ >
136
+ {DownProps.children ?? <IconSvg src={iconMin} size='small' />}
137
+ </Fab>
138
+ </Box>
120
139
  ),
121
140
  endAdornment: (
122
- <IconButton
123
- aria-label={i18n._(/* i18n */ 'Increase')}
124
- size='medium'
125
- edge='end'
126
- onPointerDown={() => setDirection('up')}
127
- onPointerUp={() => setDirection(null)}
128
- // disabled={textFieldProps.disabled || disabled === 'max'}
129
- tabIndex={-1}
130
- color='inherit'
131
- {...UpProps}
132
- className={`${classes.button} ${UpProps.className ?? ''}`}
133
- >
134
- {UpProps.children ?? <IconSvg src={iconPlus} size='small' />}
135
- </IconButton>
141
+ <Box>
142
+ <Fab
143
+ aria-label={i18n._(/* i18n */ 'Increase')}
144
+ size='smaller'
145
+ sx={{ boxShadow: variant === 'standard' ? 4 : 0, minHeight: '30px' }}
146
+ onPointerDown={() => setDirection('up')}
147
+ onPointerUp={() => setDirection(null)}
148
+ tabIndex={-1}
149
+ {...UpProps}
150
+ className={`${classes.button} ${UpProps.className ?? ''}`}
151
+ >
152
+ {UpProps.children ?? <IconSvg src={iconPlus} size='small' />}
153
+ </Fab>
154
+ </Box>
136
155
  ),
137
156
  }}
138
157
  onChange={(e: ChangeEvent<HTMLInputElement>) => {
@@ -144,6 +163,7 @@ export function TextInputNumber(props: TextInputNumberProps) {
144
163
  'aria-label': i18n._(/* i18n */ 'Number'),
145
164
  sx: [
146
165
  {
166
+ typography: 'body1',
147
167
  textAlign: 'center',
148
168
  '&::-webkit-inner-spin-button,&::-webkit-outer-spin-button': {
149
169
  appearance: 'none',
@@ -89,19 +89,19 @@ export const MuiButtonPill: ButtonVariants = [
89
89
  {
90
90
  props: { variant: 'pill', size: 'small' },
91
91
  style: ({ theme }) => ({
92
- '&:not(.Mui-disabled)': { boxShadow: theme.shadows[2] },
92
+ '&:not(.Mui-disabled):not(.MuiButton-disableElevation)': { boxShadow: theme.shadows[2] },
93
93
  }),
94
94
  },
95
95
  {
96
96
  props: { variant: 'pill', size: 'medium' },
97
97
  style: ({ theme }) => ({
98
- '&:not(.Mui-disabled)': { boxShadow: theme.shadows[4] },
98
+ '&:not(.Mui-disabled):not(.MuiButton-disableElevation)': { boxShadow: theme.shadows[4] },
99
99
  }),
100
100
  },
101
101
  {
102
102
  props: { variant: 'pill', size: 'large' },
103
103
  style: ({ theme }) => ({
104
- '&:not(.Mui-disabled)': { boxShadow: theme.shadows[6] },
104
+ '&:not(.Mui-disabled):not(.MuiButton-disableElevation)': { boxShadow: theme.shadows[6] },
105
105
  }),
106
106
  },
107
107
  {
@@ -161,7 +161,7 @@ export const MuiButtonInline: ButtonVariants = [
161
161
  {
162
162
  props: { variant: 'inline', size: 'small' },
163
163
  style: ({ theme }) => ({
164
- margin: `calc(${theme.spacings.xxs} / 2 * -1 )`,
164
+ margin: `calc(${theme.spacings.xxs} * -1 )`,
165
165
  padding: '3px 9px',
166
166
 
167
167
  '& .MuiLoadingButton-loadingIndicatorEnd': { right: 3 },
package/Theme/MuiFab.ts CHANGED
@@ -25,9 +25,12 @@ const defaultSizes: FabSizes = {
25
25
  * Default values picked from MUI:
26
26
  * https://github.com/mui/material-ui/blob/master/packages/mui-material/src/Fab/Fab.js
27
27
  */
28
+ smaller: '30px',
28
29
  small: '40px',
29
30
  medium: '48px',
30
31
  large: '54px',
32
+ responsiveSmall: responsiveVal(30, 40),
33
+ responsiveMedium: responsiveVal(36, 48),
31
34
  responsive: responsiveVal(40, 54),
32
35
  }
33
36
 
@@ -43,6 +46,9 @@ export const useFabSize = (size: FabSize) => {
43
46
  declare module '@mui/material/Fab/Fab' {
44
47
  interface FabPropsSizeOverrides {
45
48
  responsive: true
49
+ responsiveSmall: true
50
+ responsiveMedium: true
51
+ smaller: true
46
52
  }
47
53
  // todo: Wait for the color prop to be exendable and then add inverted
48
54
  // https://github.com/mui/material-ui/blob/master/packages/mui-material/src/Fab/Fab.js#L193-L202
@@ -60,7 +66,15 @@ function fabWidthHeight(size: FabSize, theme: Theme) {
60
66
 
61
67
  type FabVariants = NonNullable<ComponentsVariants['MuiFab']>
62
68
 
63
- const sizes: FabSize[] = ['small', 'medium', 'large', 'responsive']
69
+ const sizes: FabSize[] = [
70
+ 'smaller',
71
+ 'small',
72
+ 'medium',
73
+ 'large',
74
+ 'responsive',
75
+ 'responsiveSmall',
76
+ 'responsiveMedium',
77
+ ]
64
78
 
65
79
  /**
66
80
  * This defines the sizes for the added responsive variant.
@@ -5,6 +5,13 @@ export type DateTimeFormatProps = Intl.DateTimeFormatOptions
5
5
 
6
6
  export function useDateTimeFormat(props?: DateTimeFormatProps) {
7
7
  const { locale } = useRouter()
8
- const formatter = useMemo(() => new Intl.DateTimeFormat(locale, props), [locale, props])
8
+
9
+ // Remove optional dialect from locale, which Intl.NumberFormat does not support.
10
+ const strippedLocale = locale?.split('-', 2).join('-')
11
+
12
+ const formatter = useMemo(
13
+ () => new Intl.DateTimeFormat(strippedLocale, props),
14
+ [strippedLocale, props],
15
+ )
9
16
  return formatter
10
17
  }
@@ -5,6 +5,13 @@ export type NumberFormatProps = Intl.NumberFormatOptions
5
5
 
6
6
  export function useNumberFormat(props?: NumberFormatProps) {
7
7
  const { locale } = useRouter()
8
- const formatter = useMemo(() => new Intl.NumberFormat(locale, props), [locale, props])
8
+
9
+ // Remove optional dialect from locale, which Intl.NumberFormat does not support.
10
+ const strippedLocale = locale?.split('-', 2).join('-')
11
+
12
+ const formatter = useMemo(
13
+ () => new Intl.NumberFormat(strippedLocale, props),
14
+ [strippedLocale, props],
15
+ )
9
16
  return formatter
10
17
  }
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": "7.0.0-canary.21",
5
+ "version": "7.0.0",
6
6
  "author": "",
7
7
  "license": "MIT",
8
8
  "sideEffects": false,
@@ -14,29 +14,30 @@
14
14
  }
15
15
  },
16
16
  "dependencies": {
17
- "@emotion/cache": "^11.10.5",
18
- "@emotion/react": "^11.10.6",
19
- "@emotion/server": "^11.4.0",
20
- "@emotion/styled": "^11.10.6",
21
- "@graphcommerce/framer-next-pages": "7.0.0-canary.21",
22
- "@graphcommerce/framer-scroller": "7.0.0-canary.21",
23
- "@graphcommerce/framer-utils": "7.0.0-canary.21",
24
- "@graphcommerce/image": "7.0.0-canary.21",
17
+ "@emotion/cache": "^11.11.0",
18
+ "@emotion/react": "^11.11.1",
19
+ "@emotion/server": "^11.11.0",
20
+ "@emotion/styled": "^11.11.0",
21
+ "@graphcommerce/framer-next-pages": "7.0.0",
22
+ "@graphcommerce/framer-scroller": "7.0.0",
23
+ "@graphcommerce/framer-utils": "7.0.0",
24
+ "@graphcommerce/image": "7.0.0",
25
25
  "cookie": "^0.5.0",
26
26
  "react-is": "^18.2.0",
27
27
  "schema-dts": "^1.1.0"
28
28
  },
29
29
  "devDependencies": {
30
- "@graphcommerce/eslint-config-pwa": "7.0.0-canary.21",
31
- "@graphcommerce/prettier-config-pwa": "7.0.0-canary.21",
32
- "@graphcommerce/typescript-config-pwa": "7.0.0-canary.21",
30
+ "@graphcommerce/eslint-config-pwa": "7.0.0",
31
+ "@graphcommerce/prettier-config-pwa": "7.0.0",
32
+ "@graphcommerce/typescript-config-pwa": "7.0.0",
33
33
  "@types/cookie": "^0.5.1",
34
- "@types/react-is": "^17.0.3",
35
- "typescript": "4.9.5"
34
+ "@types/react-is": "^18.2.1",
35
+ "typescript": "5.1.3"
36
36
  },
37
37
  "peerDependencies": {
38
- "@lingui/core": "^3.13.2",
39
- "@lingui/react": "^3.13.2",
38
+ "@lingui/core": "^4.2.1",
39
+ "@lingui/react": "^4.2.1",
40
+ "@lingui/macro": "^4.2.1",
40
41
  "@mui/lab": "^5.0.0-alpha.68",
41
42
  "@mui/material": "^5.10.16",
42
43
  "framer-motion": "^10.0.0",