@sanity/ui 0.38.3-next.10 → 0.38.3-next.30
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/dist/sanity-ui.esm.js +9830 -0
- package/dist/sanity-ui.esm.js.map +1 -0
- package/dist/sanity-ui.js +9973 -1
- package/dist/sanity-ui.js.map +1 -1
- package/dist/types/src/index.d.ts +1 -0
- package/package.json +14 -16
- package/src/__workshop__/constants.ts +1 -0
- package/src/components/autocomplete/autocomplete.tsx +24 -25
- package/src/components/menu/menu.test.tsx +2 -0
- package/src/components/toast/toast.test.tsx +2 -0
- package/src/primitives/badge/badge.test.tsx +2 -0
- package/src/primitives/button/button.test.tsx +2 -0
- package/src/primitives/textInput/textInput.tsx +1 -0
- package/src/styles/margin/marginsStyle.test.ts +2 -0
- package/src/styles/padding/paddingStyle.test.ts +2 -0
- package/src/theme/lib/color-fns/color-fns.test.ts +2 -0
- package/src/theme/lib/theme/color/color.test.ts +3 -1
- package/src/theme/theme.test.tsx +2 -0
- package/src/utils/boundaryElement/boundaryElement.test.tsx +2 -0
- package/src/utils/layer/layer.test.tsx +2 -0
- package/src/utils/portal/portal.test.tsx +2 -0
- package/dist/sanity-ui.cjs +0 -2
- package/dist/sanity-ui.cjs.map +0 -1
|
@@ -13557,6 +13557,7 @@ export declare type TextInputType =
|
|
|
13557
13557
|
| 'time'
|
|
13558
13558
|
| 'text'
|
|
13559
13559
|
| 'week'
|
|
13560
|
+
| 'color'
|
|
13560
13561
|
|
|
13561
13562
|
/**
|
|
13562
13563
|
* @public
|
package/package.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/ui",
|
|
3
|
-
"version": "0.38.3-next.
|
|
3
|
+
"version": "0.38.3-next.30+8cd982e0",
|
|
4
4
|
"sideEffects": false,
|
|
5
|
-
"source": "./src/index.ts",
|
|
6
|
-
"module": "./dist/sanity-ui.js",
|
|
7
5
|
"types": "./dist/types/src/index.d.ts",
|
|
8
|
-
"
|
|
6
|
+
"source": "./src/index.ts",
|
|
7
|
+
"module": "./dist/sanity-ui.esm.js",
|
|
8
|
+
"main": "./dist/sanity-ui.js",
|
|
9
9
|
"exports": {
|
|
10
10
|
".": {
|
|
11
11
|
"types": "./dist/types/src/index.d.ts",
|
|
12
12
|
"source": "./src/index.ts",
|
|
13
|
-
"import": "./dist/sanity-ui.js",
|
|
14
|
-
"require": "./dist/sanity-ui.
|
|
15
|
-
"default": "./dist/sanity-ui.js"
|
|
13
|
+
"import": "./dist/sanity-ui.esm.js",
|
|
14
|
+
"require": "./dist/sanity-ui.js",
|
|
15
|
+
"default": "./dist/sanity-ui.esm.js"
|
|
16
16
|
}
|
|
17
17
|
},
|
|
18
18
|
"files": [
|
|
@@ -33,9 +33,9 @@
|
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@popperjs/core": "^2.11.6",
|
|
36
|
-
"@sanity/color": "2.1.17-next.
|
|
37
|
-
"@sanity/icons": "1.3.7-next.
|
|
38
|
-
"framer-motion": "^7.
|
|
36
|
+
"@sanity/color": "2.1.17-next.30+8cd982e0",
|
|
37
|
+
"@sanity/icons": "1.3.7-next.30+8cd982e0",
|
|
38
|
+
"framer-motion": "^7.5.2",
|
|
39
39
|
"popper-max-size-modifier": "^0.2.0",
|
|
40
40
|
"react-is": "^18.2.0",
|
|
41
41
|
"react-popper": "^2.3.0",
|
|
@@ -44,19 +44,17 @@
|
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@floating-ui/react-dom": "^1.0.0",
|
|
46
46
|
"@juggle/resize-observer": "^3.4.0",
|
|
47
|
-
"@testing-library/dom": "^8.17.1",
|
|
48
|
-
"@testing-library/jest-dom": "^5.16.5",
|
|
49
|
-
"@testing-library/react": "^13.4.0",
|
|
50
47
|
"@types/refractor": "^3.0.2",
|
|
51
|
-
"framer-motion": "^7.3.5",
|
|
52
48
|
"react": "^18.2.0",
|
|
53
49
|
"react-dom": "^18.2.0",
|
|
50
|
+
"react-is": "^18.2.0",
|
|
54
51
|
"react-refractor": "^2.1.7",
|
|
55
|
-
"styled-components": "^5.3.
|
|
52
|
+
"styled-components": "^5.3.6"
|
|
56
53
|
},
|
|
57
54
|
"peerDependencies": {
|
|
58
55
|
"react": "^18",
|
|
59
56
|
"react-dom": "^18",
|
|
57
|
+
"react-is": "^18",
|
|
60
58
|
"styled-components": "^5.2"
|
|
61
59
|
},
|
|
62
60
|
"repository": {
|
|
@@ -76,5 +74,5 @@
|
|
|
76
74
|
"publishConfig": {
|
|
77
75
|
"access": "public"
|
|
78
76
|
},
|
|
79
|
-
"gitHead": "
|
|
77
|
+
"gitHead": "8cd982e0c4fdd874021bc430ed3501e4ef3489a4"
|
|
80
78
|
}
|
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
import {ChevronDownIcon} from '@sanity/icons'
|
|
2
|
-
import {
|
|
3
|
-
cloneElement,
|
|
4
|
-
forwardRef,
|
|
5
|
-
useCallback,
|
|
6
|
-
useEffect,
|
|
7
|
-
useMemo,
|
|
8
|
-
useReducer,
|
|
9
|
-
useRef,
|
|
10
|
-
useState,
|
|
11
|
-
} from 'react'
|
|
2
|
+
import {cloneElement, forwardRef, useCallback, useEffect, useMemo, useReducer, useRef} from 'react'
|
|
12
3
|
import {EMPTY_ARRAY, EMPTY_RECORD} from '../../constants'
|
|
13
4
|
import {_hasFocus, _raf, focusFirstDescendant} from '../../helpers'
|
|
14
5
|
import {useForwardedRef, useArrayProp} from '../../hooks'
|
|
@@ -164,15 +155,21 @@ const InnerAutocomplete = forwardRef(function InnerAutocomplete<
|
|
|
164
155
|
typeof renderOptionProp === 'function' ? renderOptionProp : defaultRenderOption
|
|
165
156
|
const filterOption =
|
|
166
157
|
typeof filterOptionProp === 'function' ? filterOptionProp : defaultFilterOption
|
|
167
|
-
|
|
168
|
-
|
|
158
|
+
|
|
159
|
+
// Element refs
|
|
160
|
+
const rootElementRef = useRef<HTMLDivElement | null>(null)
|
|
161
|
+
const resultsPopoverElementRef = useRef<HTMLDivElement | null>(null)
|
|
169
162
|
const inputElementRef = useRef<HTMLInputElement | null>(null)
|
|
170
163
|
const listBoxElementRef = useRef<HTMLDivElement | null>(null)
|
|
164
|
+
|
|
165
|
+
// Value refs
|
|
171
166
|
const listFocusedRef = useRef(false)
|
|
172
167
|
const valueRef = useRef(value)
|
|
173
168
|
const valuePropRef = useRef(valueProp)
|
|
174
|
-
const forwardedRef = useForwardedRef(ref)
|
|
175
169
|
const popoverMouseWithinRef = useRef(false)
|
|
170
|
+
|
|
171
|
+
const forwardedRef = useForwardedRef(ref)
|
|
172
|
+
|
|
176
173
|
const listBoxId = `${id}-listbox`
|
|
177
174
|
const options = Array.isArray(optionsProp) ? optionsProp : EMPTY_ARRAY
|
|
178
175
|
const padding = useArrayProp(paddingProp)
|
|
@@ -199,8 +196,8 @@ const InnerAutocomplete = forwardRef(function InnerAutocomplete<
|
|
|
199
196
|
}
|
|
200
197
|
|
|
201
198
|
const elements: HTMLElement[] = (relatedElements || []).concat(
|
|
202
|
-
|
|
203
|
-
|
|
199
|
+
rootElementRef.current ? [rootElementRef.current] : [],
|
|
200
|
+
resultsPopoverElementRef.current ? [resultsPopoverElementRef.current] : []
|
|
204
201
|
)
|
|
205
202
|
|
|
206
203
|
let focusInside = false
|
|
@@ -222,7 +219,7 @@ const InnerAutocomplete = forwardRef(function InnerAutocomplete<
|
|
|
222
219
|
}
|
|
223
220
|
}, 0)
|
|
224
221
|
},
|
|
225
|
-
[onBlur, onQueryChange, relatedElements
|
|
222
|
+
[onBlur, onQueryChange, relatedElements]
|
|
226
223
|
)
|
|
227
224
|
|
|
228
225
|
const handleRootFocus = useCallback((event: React.FocusEvent) => {
|
|
@@ -362,6 +359,7 @@ const InnerAutocomplete = forwardRef(function InnerAutocomplete<
|
|
|
362
359
|
|
|
363
360
|
// Change the value when `value` prop changes
|
|
364
361
|
useEffect(() => {
|
|
362
|
+
// If `valueProp` changed
|
|
365
363
|
if (valueProp !== valuePropRef.current) {
|
|
366
364
|
valuePropRef.current = valueProp
|
|
367
365
|
|
|
@@ -373,17 +371,18 @@ const InnerAutocomplete = forwardRef(function InnerAutocomplete<
|
|
|
373
371
|
return
|
|
374
372
|
}
|
|
375
373
|
|
|
376
|
-
|
|
374
|
+
// If `valueProp` is not equal to `value`
|
|
375
|
+
if (valueProp !== valueRef.current) {
|
|
376
|
+
valueRef.current = valueProp || null
|
|
377
|
+
|
|
377
378
|
dispatch({type: 'value/change', value: valueProp || null})
|
|
378
379
|
}
|
|
379
|
-
}, [valueProp
|
|
380
|
+
}, [valueProp])
|
|
380
381
|
|
|
381
382
|
// Reset active item when closing
|
|
382
383
|
useEffect(() => {
|
|
383
|
-
if (!focused) {
|
|
384
|
-
|
|
385
|
-
dispatch({type: 'root/setActiveValue', value: valueRef.current})
|
|
386
|
-
}
|
|
384
|
+
if (!focused && valueRef.current) {
|
|
385
|
+
dispatch({type: 'root/setActiveValue', value: valueRef.current})
|
|
387
386
|
}
|
|
388
387
|
}, [focused])
|
|
389
388
|
|
|
@@ -622,7 +621,7 @@ const InnerAutocomplete = forwardRef(function InnerAutocomplete<
|
|
|
622
621
|
onMouseEnter: handlePopoverMouseEnter,
|
|
623
622
|
onMouseLeave: handlePopoverMouseLeave,
|
|
624
623
|
},
|
|
625
|
-
|
|
624
|
+
resultsPopoverElementRef
|
|
626
625
|
)
|
|
627
626
|
}
|
|
628
627
|
|
|
@@ -644,7 +643,7 @@ const InnerAutocomplete = forwardRef(function InnerAutocomplete<
|
|
|
644
643
|
placement={AUTOCOMPLETE_POPOVER_PLACEMENT}
|
|
645
644
|
portal
|
|
646
645
|
radius={radius}
|
|
647
|
-
ref={
|
|
646
|
+
ref={resultsPopoverElementRef}
|
|
648
647
|
referenceElement={inputElementRef.current}
|
|
649
648
|
{...popover}
|
|
650
649
|
/>
|
|
@@ -666,7 +665,7 @@ const InnerAutocomplete = forwardRef(function InnerAutocomplete<
|
|
|
666
665
|
onBlur={handleRootBlur}
|
|
667
666
|
onFocus={handleRootFocus}
|
|
668
667
|
onKeyDown={handleRootKeyDown}
|
|
669
|
-
ref={
|
|
668
|
+
ref={rootElementRef}
|
|
670
669
|
>
|
|
671
670
|
{input}
|
|
672
671
|
{results}
|
package/src/theme/theme.test.tsx
CHANGED