@sanity/ui 2.10.0-corel.0 → 2.10.1
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/_chunks-cjs/getTheme_v2.js +110 -54
- package/dist/_chunks-cjs/getTheme_v2.js.map +1 -1
- package/dist/_chunks-es/getTheme_v2.mjs +110 -54
- package/dist/_chunks-es/getTheme_v2.mjs.map +1 -1
- package/dist/_legacy/getTheme_v2.esm.js +110 -54
- package/dist/_legacy/getTheme_v2.esm.js.map +1 -1
- package/dist/index.d.mts +43 -54
- package/dist/index.d.ts +43 -54
- package/dist/index.esm.js +3323 -3046
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +3322 -3046
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3323 -3046
- package/dist/index.mjs.map +1 -1
- package/dist/theme.d.mts +9 -9
- package/dist/theme.d.ts +9 -9
- package/dist/theme.esm.js +1144 -592
- package/dist/theme.esm.js.map +1 -1
- package/dist/theme.js +1144 -592
- package/dist/theme.js.map +1 -1
- package/dist/theme.mjs +1144 -592
- package/dist/theme.mjs.map +1 -1
- package/package.json +78 -64
- package/src/core/__workshop__/constants.ts +15 -19
- package/src/core/components/autocomplete/__workshop__/constrainedHeight.tsx +1 -1
- package/src/core/components/autocomplete/autocomplete.tsx +4 -3
- package/src/core/components/autocomplete/autocompleteOption.tsx +1 -1
- package/src/core/components/breadcrumbs/__workshop__/example.tsx +1 -3
- package/src/core/components/breadcrumbs/__workshop__/index.ts +0 -5
- package/src/core/components/breadcrumbs/breadcrumbs.styles.ts +13 -1
- package/src/core/components/breadcrumbs/breadcrumbs.tsx +31 -39
- package/src/core/components/dialog/dialog.tsx +5 -3
- package/src/core/components/dialog/dialogProvider.tsx +1 -1
- package/src/core/components/menu/__workshop__/asComponent.tsx +1 -1
- package/src/core/components/menu/__workshop__/tones.tsx +5 -6
- package/src/core/components/menu/menu.test.tsx +0 -2
- package/src/core/components/menu/menu.tsx +15 -11
- package/src/core/components/menu/menuButton.tsx +16 -38
- package/src/core/components/menu/menuGroup.tsx +4 -3
- package/src/core/components/menu/menuItem.tsx +5 -2
- package/src/core/components/tab/tabList.tsx +4 -12
- package/src/core/components/toast/__workshop__/hook.tsx +1 -1
- package/src/core/components/toast/toast.test.tsx +0 -1
- package/src/core/components/toast/toast.tsx +3 -3
- package/src/core/components/toast/toastProvider.tsx +8 -8
- package/src/core/components/toast/toastState.ts +6 -0
- package/src/core/components/tree/tree.tsx +1 -1
- package/src/core/components/tree/treeGroup.tsx +1 -1
- package/src/core/components/tree/treeItem.tsx +1 -1
- package/src/core/constants.ts +1 -1
- package/src/core/hooks/useArrayProp.ts +14 -9
- package/src/core/hooks/useDelayedState.ts +1 -1
- package/src/core/hooks/useElementRect/__workshop__/example.tsx +2 -2
- package/src/core/hooks/usePrefersDark.hydration.test.tsx +0 -1
- package/src/core/hooks/usePrefersReducedMotion.hydration.test.tsx +0 -1
- package/src/core/lib/globalScope.ts +0 -1
- package/src/core/primitives/avatar/avatar.tsx +1 -1
- package/src/core/primitives/avatar/avatarStack.tsx +2 -5
- package/src/core/primitives/badge/__workshop__/tones.tsx +6 -13
- package/src/core/primitives/badge/badge.tsx +1 -1
- package/src/core/primitives/box/box.tsx +1 -1
- package/src/core/primitives/button/__workshop__/custom.tsx +4 -3
- package/src/core/primitives/button/__workshop__/props.tsx +1 -1
- package/src/core/primitives/button/button.tsx +7 -12
- package/src/core/primitives/button/styles.ts +1 -1
- package/src/core/primitives/card/__workshop__/allTones.tsx +6 -8
- package/src/core/primitives/card/__workshop__/asButton.tsx +42 -24
- package/src/core/primitives/card/__workshop__/asComponent.tsx +2 -2
- package/src/core/primitives/card/__workshop__/checkered.tsx +17 -7
- package/src/core/primitives/card/__workshop__/interactive.tsx +10 -3
- package/src/core/primitives/card/__workshop__/listNavigation.tsx +5 -3
- package/src/core/primitives/card/__workshop__/props.tsx +7 -5
- package/src/core/primitives/card/__workshop__/selected.tsx +4 -1
- package/src/core/primitives/checkbox/__workshop__/tones.tsx +6 -0
- package/src/core/primitives/code/__workshop__/props.tsx +1 -1
- package/src/core/primitives/code/code.tsx +1 -2
- package/src/core/primitives/container/__workshop__/example.tsx +1 -1
- package/src/core/primitives/flex/__workshop__/example.tsx +3 -3
- package/src/core/primitives/flex/flex.tsx +1 -5
- package/src/core/primitives/grid/__workshop__/responsive.tsx +12 -12
- package/src/core/primitives/heading/__workshop__/opticalAlignment.tsx +13 -25
- package/src/core/primitives/heading/heading.tsx +2 -2
- package/src/core/primitives/inline/__workshop__/plain.tsx +3 -3
- package/src/core/primitives/inline/inline.tsx +0 -1
- package/src/core/primitives/kbd/kbd.tsx +1 -1
- package/src/core/primitives/label/__workshop__/opticalAlignment.tsx +6 -6
- package/src/core/primitives/label/label.tsx +1 -1
- package/src/core/primitives/popover/__workshop__/AlignedStory.tsx +1 -1
- package/src/core/primitives/popover/__workshop__/MatchReferenceWidthStory.tsx +3 -3
- package/src/core/primitives/popover/__workshop__/OpenOnMountStory.tsx +1 -1
- package/src/core/primitives/popover/__workshop__/PlainStory.tsx +1 -1
- package/src/core/primitives/popover/__workshop__/SidePanelStory.tsx +1 -1
- package/src/core/primitives/popover/__workshop__/TestStory.tsx +2 -2
- package/src/core/primitives/popover/popover.tsx +10 -10
- package/src/core/primitives/radio/__workshop__/plain.tsx +2 -2
- package/src/core/primitives/select/__workshop__/readOnly.tsx +1 -1
- package/src/core/primitives/stack/stack.tsx +1 -1
- package/src/core/primitives/text/__workshop__/example.tsx +6 -6
- package/src/core/primitives/text/__workshop__/opticalAlignment.tsx +11 -21
- package/src/core/primitives/text/styles.ts +0 -1
- package/src/core/primitives/text/text.tsx +3 -5
- package/src/core/primitives/textArea/__workshop__/plain.tsx +1 -1
- package/src/core/primitives/textInput/__workshop__/index.ts +0 -5
- package/src/core/primitives/textInput/__workshop__/plain.tsx +1 -2
- package/src/core/primitives/textInput/__workshop__/readOnly.tsx +6 -2
- package/src/core/primitives/textInput/__workshop__/tones.tsx +38 -0
- package/src/core/primitives/tooltip/tooltip.tsx +1 -2
- package/src/core/primitives/tooltip/tooltipDelayGroup/tooltipDelayGroupProvider.tsx +1 -1
- package/src/core/styles/card/_cardColorStyle.ts +8 -8
- package/src/core/styles/flex/flexStyle.ts +0 -18
- package/src/core/styles/flex/types.ts +0 -2
- package/src/core/theme/__workshop__/build/story.tsx +1 -3
- package/src/core/theme/__workshop__/debug/story.tsx +18 -13
- package/src/core/theme/theme.test.tsx +0 -1
- package/src/core/theme/themeColorProvider.tsx +1 -1
- package/src/core/theme/themeProvider.tsx +5 -7
- package/src/core/utils/arrow/arrow.tsx +1 -1
- package/src/core/utils/boundaryElement/boundaryElement.test.tsx +0 -1
- package/src/core/utils/boundaryElement/boundaryElementProvider.tsx +3 -1
- package/src/core/utils/elementQuery/elementQuery.tsx +16 -17
- package/src/core/utils/layer/layer.test.tsx +0 -1
- package/src/core/utils/layer/layer.tsx +9 -1
- package/src/core/utils/layer/layerProvider.tsx +2 -2
- package/src/core/utils/portal/portal.test.tsx +0 -1
- package/src/core/utils/portal/portalProvider.tsx +1 -1
- package/src/core/utils/srOnly/srOnly.tsx +1 -1
- package/src/core/utils/virtualList/virtualList.tsx +10 -3
- package/src/theme/build/_deprecated/color/muted/createMuted.ts +2 -2
- package/src/theme/build/buildColorTheme.ts +12 -8
- package/src/theme/build/merge.ts +0 -2
- package/src/theme/build/renderColorTheme.ts +54 -232
- package/src/theme/defaults/colorTokens.ts +13 -18
- package/src/theme/system/color/_constants.ts +6 -10
- package/src/theme/system/css.ts +1 -2
- package/src/theme/versioning/themeColor_v0_v2.ts +26 -26
- package/src/theme/versioning/v0_v2.ts +4 -4
- package/src/core/components/autocomplete/__workshop__/.eslintrc +0 -5
- package/src/core/components/breadcrumbs/__workshop__/.eslintrc +0 -5
- package/src/core/components/breadcrumbs/__workshop__/buttons.tsx +0 -58
- package/src/core/components/dialog/__workshop__/.eslintrc +0 -5
- package/src/core/components/hotkeys/__workshop__/.eslintrc +0 -5
- package/src/core/components/menu/__workshop__/.eslintrc +0 -5
- package/src/core/components/skeleton/__workshop__/.eslintrc +0 -5
- package/src/core/components/tab/__workshop__/.eslintrc +0 -5
- package/src/core/components/toast/__workshop__/.eslintrc +0 -5
- package/src/core/components/tree/__workshop__/.eslintrc +0 -5
- package/src/core/hooks/useElementRect/__workshop__/.eslintrc +0 -5
- package/src/core/hooks/useMediaIndex/__workshop__/.eslintrc +0 -5
- package/src/core/primitives/avatar/__workshop__/.eslintrc +0 -5
- package/src/core/primitives/badge/__workshop__/.eslintrc +0 -5
- package/src/core/primitives/box/__workshop__/.eslintrc +0 -5
- package/src/core/primitives/button/__workshop__/.eslintrc +0 -5
- package/src/core/primitives/card/__workshop__/.eslintrc +0 -5
- package/src/core/primitives/checkbox/__workshop__/.eslintrc +0 -5
- package/src/core/primitives/code/__workshop__/.eslintrc +0 -5
- package/src/core/primitives/container/__workshop__/.eslintrc +0 -5
- package/src/core/primitives/flex/__workshop__/.eslintrc +0 -5
- package/src/core/primitives/grid/__workshop__/.eslintrc +0 -5
- package/src/core/primitives/heading/__workshop__/.eslintrc +0 -5
- package/src/core/primitives/inline/__workshop__/.eslintrc +0 -5
- package/src/core/primitives/kbd/__workshop__/.eslintrc +0 -5
- package/src/core/primitives/label/__workshop__/.eslintrc +0 -5
- package/src/core/primitives/popover/__workshop__/.eslintrc +0 -5
- package/src/core/primitives/radio/__workshop__/.eslintrc +0 -5
- package/src/core/primitives/select/__workshop__/.eslintrc +0 -5
- package/src/core/primitives/spinner/__workshop__/.eslintrc +0 -5
- package/src/core/primitives/stack/__workshop__/.eslintrc +0 -5
- package/src/core/primitives/switch/__workshop__/.eslintrc +0 -5
- package/src/core/primitives/text/__workshop__/.eslintrc +0 -5
- package/src/core/primitives/textArea/__workshop__/.eslintrc +0 -5
- package/src/core/primitives/textInput/__workshop__/.eslintrc +0 -5
- package/src/core/primitives/textInput/__workshop__/multipleTones.tsx +0 -20
- package/src/core/primitives/tooltip/__workshop__/.eslintrc +0 -5
- package/src/core/theme/__workshop__/.eslintrc +0 -5
- package/src/core/utils/boundaryElement/__workshop__/.eslintrc +0 -5
- package/src/core/utils/elementQuery/__workshop__/.eslintrc +0 -5
- package/src/core/utils/layer/__workshop__/.eslintrc +0 -5
- package/src/core/utils/portal/__workshop__/.eslintrc +0 -5
- package/src/core/utils/virtualList/__workshop__/.eslintrc +0 -5
|
@@ -12,7 +12,7 @@ import {Text} from '../../text'
|
|
|
12
12
|
import {Popover} from '../popover'
|
|
13
13
|
import {PopoverUpdateCallback} from '../types'
|
|
14
14
|
|
|
15
|
-
export default function TestStory(): ReactElement {
|
|
15
|
+
export default function TestStory(): ReactElement<any> {
|
|
16
16
|
const [portalElement, setPortalElement] = useState<HTMLDivElement | null>(null)
|
|
17
17
|
const [boundaryElement, setBoundaryElement] = useState<HTMLDivElement | null>(null)
|
|
18
18
|
|
|
@@ -30,7 +30,7 @@ export default function TestStory(): ReactElement {
|
|
|
30
30
|
|
|
31
31
|
const text = useText('Text', 'Test')
|
|
32
32
|
|
|
33
|
-
const updateRef = useRef<PopoverUpdateCallback>()
|
|
33
|
+
const updateRef = useRef<PopoverUpdateCallback>(undefined)
|
|
34
34
|
|
|
35
35
|
const button = (
|
|
36
36
|
<Button text="reference" selected style={{width: referenceWide ? 300 : undefined}} />
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
1
|
import {
|
|
3
2
|
Middleware,
|
|
4
3
|
RootBoundary,
|
|
@@ -60,7 +59,7 @@ export interface PopoverProps
|
|
|
60
59
|
arrow?: boolean
|
|
61
60
|
/** @deprecated Use `floatingBoundary` and/or `referenceBoundary` instead */
|
|
62
61
|
boundaryElement?: HTMLElement | null
|
|
63
|
-
children?: React.ReactElement
|
|
62
|
+
children?: React.ReactElement<any>
|
|
64
63
|
/**
|
|
65
64
|
* When `true`, prevent overflow within the current boundary:
|
|
66
65
|
* - by flipping on its side axis
|
|
@@ -118,7 +117,7 @@ export const Popover = memo(
|
|
|
118
117
|
props: PopoverProps &
|
|
119
118
|
Omit<React.HTMLProps<HTMLDivElement>, 'as' | 'children' | 'content' | 'width'>,
|
|
120
119
|
forwardedRef: React.ForwardedRef<HTMLDivElement>,
|
|
121
|
-
): React.ReactElement {
|
|
120
|
+
): React.ReactElement<any> {
|
|
122
121
|
const {container, layer} = useTheme_v2()
|
|
123
122
|
const boundaryElementContext = useBoundaryElement()
|
|
124
123
|
|
|
@@ -199,7 +198,7 @@ export const Popover = memo(
|
|
|
199
198
|
}, [maxWidth])
|
|
200
199
|
|
|
201
200
|
// Keep track of reference element width (see `size` middleware below)
|
|
202
|
-
const referenceWidthRef = useRef<number>()
|
|
201
|
+
const referenceWidthRef = useRef<number>(undefined)
|
|
203
202
|
|
|
204
203
|
// Force apply width & max width to floating element
|
|
205
204
|
useEffect(() => {
|
|
@@ -366,9 +365,12 @@ export const Popover = memo(
|
|
|
366
365
|
)
|
|
367
366
|
|
|
368
367
|
const child = useMemo(() => {
|
|
368
|
+
// If a reference element is defined, we don't need to clone the child
|
|
369
|
+
if (referenceElement) return childProp
|
|
370
|
+
|
|
369
371
|
if (!childProp) return null
|
|
370
372
|
|
|
371
|
-
return cloneElement(childProp, {ref:
|
|
373
|
+
return cloneElement(childProp, {ref: setReference})
|
|
372
374
|
}, [childProp, referenceElement, setReference])
|
|
373
375
|
|
|
374
376
|
useEffect(() => {
|
|
@@ -382,10 +384,8 @@ export const Popover = memo(
|
|
|
382
384
|
}, [update, updateRef])
|
|
383
385
|
|
|
384
386
|
useEffect(() => {
|
|
385
|
-
if (referenceElement)
|
|
386
|
-
|
|
387
|
-
}
|
|
388
|
-
}, [referenceElement, refs, child])
|
|
387
|
+
if (referenceElement) refs.setReference(referenceElement)
|
|
388
|
+
}, [referenceElement, refs])
|
|
389
389
|
|
|
390
390
|
if (disabled) {
|
|
391
391
|
return childProp || <></>
|
|
@@ -448,7 +448,7 @@ Popover.displayName = 'Memo(ForwardRef(Popover))'
|
|
|
448
448
|
// https://github.com/facebook/react/pull/28348
|
|
449
449
|
//
|
|
450
450
|
// Access the ref using the method that doesn't yield a warning.
|
|
451
|
-
function getElementRef(element: React.ReactElement) {
|
|
451
|
+
function getElementRef(element: React.ReactElement<any>) {
|
|
452
452
|
// React <=18 in DEV
|
|
453
453
|
let getter = Object.getOwnPropertyDescriptor(element.props, 'ref')?.get
|
|
454
454
|
let mayWarn = getter && 'isReactWarning' in getter && getter.isReactWarning
|
|
@@ -2,8 +2,8 @@ import {Flex, Radio} from '@sanity/ui'
|
|
|
2
2
|
import {useAction, useBoolean} from '@sanity/ui-workshop'
|
|
3
3
|
|
|
4
4
|
export default function PlainStory() {
|
|
5
|
-
const checked = useBoolean('Checked
|
|
6
|
-
const disabled = useBoolean('Disabled
|
|
5
|
+
const checked = useBoolean('Checked', false, 'Props')
|
|
6
|
+
const disabled = useBoolean('Disabled', false, 'Props')
|
|
7
7
|
const id = 'radioStory'
|
|
8
8
|
const name = 'radioStory'
|
|
9
9
|
const onBlur = useAction('onBlur')
|
|
@@ -9,7 +9,7 @@ export default function ReadOnlyStory() {
|
|
|
9
9
|
Select
|
|
10
10
|
</Label>
|
|
11
11
|
|
|
12
|
-
<Select id="select-example"
|
|
12
|
+
<Select id="select-example" readOnly>
|
|
13
13
|
<option value="a">Option A</option>
|
|
14
14
|
<option value="b">Option B</option>
|
|
15
15
|
<option value="c">Option C</option>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {Container, Flex, Text} from '@sanity/ui'
|
|
2
2
|
import {useBoolean, useSelect, useText} from '@sanity/ui-workshop'
|
|
3
3
|
import {
|
|
4
4
|
WORKSHOP_TEXT_ALIGN_OPTIONS,
|
|
@@ -11,7 +11,7 @@ export default function TextStory() {
|
|
|
11
11
|
const accent = useBoolean('Accent', false, 'Props')
|
|
12
12
|
const align = useSelect('Align', WORKSHOP_TEXT_ALIGN_OPTIONS, '', 'Props') || undefined
|
|
13
13
|
const muted = useBoolean('Muted', false, 'Props')
|
|
14
|
-
const size = useSelect('Size', WORKSHOP_TEXT_SIZE_OPTIONS,
|
|
14
|
+
const size = useSelect('Size', WORKSHOP_TEXT_SIZE_OPTIONS, 1, 'Props')
|
|
15
15
|
const text = useText('Text', 'Hello, world', 'Props')
|
|
16
16
|
|
|
17
17
|
const textOverflow =
|
|
@@ -20,8 +20,8 @@ export default function TextStory() {
|
|
|
20
20
|
const weight = useSelect('Weight', WORKSHOP_TEXT_WEIGHT_OPTIONS, '', 'Props') || undefined
|
|
21
21
|
|
|
22
22
|
return (
|
|
23
|
-
<
|
|
24
|
-
<
|
|
23
|
+
<Flex align="center" height="fill" justify="center" padding={4} sizing="border">
|
|
24
|
+
<Container width={0}>
|
|
25
25
|
<Text
|
|
26
26
|
accent={accent}
|
|
27
27
|
align={align}
|
|
@@ -32,7 +32,7 @@ export default function TextStory() {
|
|
|
32
32
|
>
|
|
33
33
|
{text}
|
|
34
34
|
</Text>
|
|
35
|
-
</
|
|
36
|
-
</
|
|
35
|
+
</Container>
|
|
36
|
+
</Flex>
|
|
37
37
|
)
|
|
38
38
|
}
|
|
@@ -6,47 +6,37 @@ export default function OpticalAlignment() {
|
|
|
6
6
|
<Box padding={[4, 5, 6]}>
|
|
7
7
|
<Stack space={1}>
|
|
8
8
|
<Flex>
|
|
9
|
-
<Card padding={0}
|
|
10
|
-
<Text
|
|
11
|
-
Hamburgefonstiv M
|
|
12
|
-
</Text>
|
|
9
|
+
<Card padding={0} tone="neutral">
|
|
10
|
+
<Text size={4}>Hamburgefonstiv M</Text>
|
|
13
11
|
</Card>
|
|
14
12
|
</Flex>
|
|
15
13
|
|
|
16
14
|
<Flex>
|
|
17
|
-
<Card padding={0}
|
|
18
|
-
<Text
|
|
19
|
-
Hamburgefonstiv M
|
|
20
|
-
</Text>
|
|
15
|
+
<Card padding={0} tone="neutral">
|
|
16
|
+
<Text size={3}>Hamburgefonstiv M</Text>
|
|
21
17
|
</Card>
|
|
22
18
|
</Flex>
|
|
23
19
|
|
|
24
20
|
<Flex>
|
|
25
|
-
<Card padding={0}
|
|
26
|
-
<Text
|
|
27
|
-
Hamburgefonstiv M
|
|
28
|
-
</Text>
|
|
21
|
+
<Card padding={0} tone="neutral">
|
|
22
|
+
<Text size={2}>Hamburgefonstiv M</Text>
|
|
29
23
|
</Card>
|
|
30
24
|
</Flex>
|
|
31
25
|
|
|
32
26
|
<Flex>
|
|
33
|
-
<Card padding={0}
|
|
34
|
-
<Text
|
|
35
|
-
Hamburgefonstiv M
|
|
36
|
-
</Text>
|
|
27
|
+
<Card padding={0} tone="neutral">
|
|
28
|
+
<Text size={1}>Hamburgefonstiv M</Text>
|
|
37
29
|
</Card>
|
|
38
30
|
</Flex>
|
|
39
31
|
|
|
40
32
|
<Flex>
|
|
41
|
-
<Card padding={0}
|
|
42
|
-
<Text
|
|
43
|
-
Hamburgefonstiv M
|
|
44
|
-
</Text>
|
|
33
|
+
<Card padding={0} tone="neutral">
|
|
34
|
+
<Text size={0}>Hamburgefonstiv M</Text>
|
|
45
35
|
</Card>
|
|
46
36
|
</Flex>
|
|
47
37
|
|
|
48
38
|
<Flex>
|
|
49
|
-
<Card padding={2}
|
|
39
|
+
<Card padding={2} tone="neutral">
|
|
50
40
|
<Text>
|
|
51
41
|
<AddCircleIcon />
|
|
52
42
|
</Text>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {ThemeFontWeightKey} from '@sanity/ui/theme'
|
|
2
|
-
import {forwardRef} from 'react'
|
|
2
|
+
import {forwardRef, type JSX} from 'react'
|
|
3
3
|
import {styled} from 'styled-components'
|
|
4
4
|
import {useArrayProp} from '../../hooks'
|
|
5
5
|
import {
|
|
@@ -25,7 +25,7 @@ export interface TextProps {
|
|
|
25
25
|
* Use `textOverflow="ellipsis"` to render text as a single line which is concatenated with a `…` symbol.
|
|
26
26
|
* @beta
|
|
27
27
|
*/
|
|
28
|
-
textOverflow?: 'ellipsis'
|
|
28
|
+
textOverflow?: 'ellipsis'
|
|
29
29
|
weight?: ThemeFontWeightKey
|
|
30
30
|
}
|
|
31
31
|
|
|
@@ -67,8 +67,6 @@ export const Text = forwardRef(function Text(
|
|
|
67
67
|
|
|
68
68
|
if (textOverflow === 'ellipsis') {
|
|
69
69
|
children = <SpanWithTextOverflow>{children}</SpanWithTextOverflow>
|
|
70
|
-
} else {
|
|
71
|
-
children = <span>{children}</span>
|
|
72
70
|
}
|
|
73
71
|
|
|
74
72
|
return (
|
|
@@ -82,7 +80,7 @@ export const Text = forwardRef(function Text(
|
|
|
82
80
|
$size={useArrayProp(size)}
|
|
83
81
|
$weight={weight}
|
|
84
82
|
>
|
|
85
|
-
{children}
|
|
83
|
+
<span>{children}</span>
|
|
86
84
|
</Root>
|
|
87
85
|
)
|
|
88
86
|
})
|
|
@@ -17,7 +17,7 @@ export default function PlainStory() {
|
|
|
17
17
|
const fontSize = useSelect('Font size', WORKSHOP_TEXT_FONT_SIZE_OPTIONS, 2, 'Props')
|
|
18
18
|
const padding = useSelect('Padding', WORKSHOP_SPACE_OPTIONS, 3, 'Props')
|
|
19
19
|
const placeholder = useText('Placeholder', '', 'Props') || undefined
|
|
20
|
-
const radius = useSelect('Radius', WORKSHOP_RADIUS_OPTIONS,
|
|
20
|
+
const radius = useSelect('Radius', WORKSHOP_RADIUS_OPTIONS, 2, 'Props')
|
|
21
21
|
const readOnly = useBoolean('Read only', false, 'Props')
|
|
22
22
|
const weight = useSelect('Weight', WORKSHOP_FONT_WEIGHT_OPTIONS, undefined, 'Props')
|
|
23
23
|
|
|
@@ -35,11 +35,6 @@ export default defineScope({
|
|
|
35
35
|
title: 'Read only',
|
|
36
36
|
component: lazy(() => import('./readOnly')),
|
|
37
37
|
},
|
|
38
|
-
{
|
|
39
|
-
name: 'multiple-tones',
|
|
40
|
-
title: 'Multiple tones',
|
|
41
|
-
component: lazy(() => import('./multipleTones')),
|
|
42
|
-
},
|
|
43
38
|
{
|
|
44
39
|
name: 'states',
|
|
45
40
|
title: 'States',
|
|
@@ -57,7 +57,7 @@ function TextInputTest(props: {inputRef: React.Ref<HTMLInputElement>}) {
|
|
|
57
57
|
const iconRight = useSelect(
|
|
58
58
|
'Icon (right)',
|
|
59
59
|
WORKSHOP_ICON_SYMBOL_OPTIONS,
|
|
60
|
-
'
|
|
60
|
+
'cube',
|
|
61
61
|
'Props',
|
|
62
62
|
) as IconSymbol
|
|
63
63
|
const padding = useSelect('Padding', WORKSHOP_SPACE_OPTIONS, 3, 'Props')
|
|
@@ -83,7 +83,6 @@ function TextInputTest(props: {inputRef: React.Ref<HTMLInputElement>}) {
|
|
|
83
83
|
icon={icon && icons[icon]}
|
|
84
84
|
iconRight={iconRight && icons[iconRight]}
|
|
85
85
|
id="text-input-example"
|
|
86
|
-
name="email"
|
|
87
86
|
onChange={handleChange}
|
|
88
87
|
padding={padding}
|
|
89
88
|
placeholder={placeholder}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import {TextInput} from '@sanity/ui'
|
|
1
|
+
import {Flex, TextInput} from '@sanity/ui'
|
|
2
2
|
|
|
3
3
|
export default function ReadOnlyStory() {
|
|
4
|
-
return
|
|
4
|
+
return (
|
|
5
|
+
<Flex padding={4}>
|
|
6
|
+
<TextInput id="text-input-example" readOnly />
|
|
7
|
+
</Flex>
|
|
8
|
+
)
|
|
5
9
|
}
|
|
@@ -3,7 +3,9 @@ import {useBoolean} from '@sanity/ui-workshop'
|
|
|
3
3
|
|
|
4
4
|
export default function TonesStory() {
|
|
5
5
|
const transparentTone = useBoolean('Transparent', true)
|
|
6
|
+
const neutralTone = useBoolean('Neutral', true)
|
|
6
7
|
const primaryTone = useBoolean('Primary', true)
|
|
8
|
+
const suggestTone = useBoolean('Suggest', true)
|
|
7
9
|
const positiveTone = useBoolean('Positive', true)
|
|
8
10
|
const cautionTone = useBoolean('Caution', true)
|
|
9
11
|
const criticalTone = useBoolean('Critical', true)
|
|
@@ -49,6 +51,24 @@ export default function TonesStory() {
|
|
|
49
51
|
</Card>
|
|
50
52
|
)}
|
|
51
53
|
|
|
54
|
+
{neutralTone && (
|
|
55
|
+
<Card padding={3} tone="neutral">
|
|
56
|
+
<TextInput
|
|
57
|
+
placeholder="neutral"
|
|
58
|
+
prefix={
|
|
59
|
+
<Box padding={3}>
|
|
60
|
+
<Text>prefix</Text>
|
|
61
|
+
</Box>
|
|
62
|
+
}
|
|
63
|
+
suffix={
|
|
64
|
+
<Box padding={3}>
|
|
65
|
+
<Text>suffix</Text>
|
|
66
|
+
</Box>
|
|
67
|
+
}
|
|
68
|
+
/>
|
|
69
|
+
</Card>
|
|
70
|
+
)}
|
|
71
|
+
|
|
52
72
|
{primaryTone && (
|
|
53
73
|
<Card padding={3} tone="primary">
|
|
54
74
|
<TextInput
|
|
@@ -67,6 +87,24 @@ export default function TonesStory() {
|
|
|
67
87
|
</Card>
|
|
68
88
|
)}
|
|
69
89
|
|
|
90
|
+
{suggestTone && (
|
|
91
|
+
<Card padding={3} tone="suggest">
|
|
92
|
+
<TextInput
|
|
93
|
+
placeholder="suggest"
|
|
94
|
+
prefix={
|
|
95
|
+
<Box padding={3}>
|
|
96
|
+
<Text>prefix</Text>
|
|
97
|
+
</Box>
|
|
98
|
+
}
|
|
99
|
+
suffix={
|
|
100
|
+
<Box padding={3}>
|
|
101
|
+
<Text>suffix</Text>
|
|
102
|
+
</Box>
|
|
103
|
+
}
|
|
104
|
+
/>
|
|
105
|
+
</Card>
|
|
106
|
+
)}
|
|
107
|
+
|
|
70
108
|
{positiveTone && (
|
|
71
109
|
<Card padding={3} tone="positive">
|
|
72
110
|
<TextInput
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
1
|
import {
|
|
3
2
|
arrow,
|
|
4
3
|
autoUpdate,
|
|
@@ -48,7 +47,7 @@ export interface TooltipProps extends Omit<LayerProps, 'as'> {
|
|
|
48
47
|
allowedAutoPlacements?: Placement[]
|
|
49
48
|
arrow?: boolean
|
|
50
49
|
boundaryElement?: HTMLElement | null
|
|
51
|
-
children?: React.ReactElement
|
|
50
|
+
children?: React.ReactElement<any>
|
|
52
51
|
content?: React.ReactNode
|
|
53
52
|
disabled?: boolean
|
|
54
53
|
fallbackPlacements?: Placement[]
|
|
@@ -28,7 +28,7 @@ export interface TooltipDelayGroupProviderProps {
|
|
|
28
28
|
*/
|
|
29
29
|
export function TooltipDelayGroupProvider(
|
|
30
30
|
props: TooltipDelayGroupProviderProps,
|
|
31
|
-
): React.ReactElement {
|
|
31
|
+
): React.ReactElement<any> {
|
|
32
32
|
const {children, delay} = props
|
|
33
33
|
const [isGroupActive, setIsGroupActive] = useDelayedState(false)
|
|
34
34
|
const [openTooltipId, setOpenTooltipId] = useDelayedState<string | null>(null)
|
|
@@ -55,10 +55,18 @@ export function _cardColorStyle(
|
|
|
55
55
|
'--card-badge-default-dot-color': color.badge.default.dot,
|
|
56
56
|
'--card-badge-default-fg-color': color.badge.default.fg,
|
|
57
57
|
'--card-badge-default-icon-color': color.badge.default.icon,
|
|
58
|
+
'--card-badge-neutral-bg-color': color.badge.neutral?.bg,
|
|
59
|
+
'--card-badge-neutral-dot-color': color.badge.neutral?.dot,
|
|
60
|
+
'--card-badge-neutral-fg-color': color.badge.neutral?.fg,
|
|
61
|
+
'--card-badge-neutral-icon-color': color.badge.neutral?.icon,
|
|
58
62
|
'--card-badge-primary-bg-color': color.badge.primary.bg,
|
|
59
63
|
'--card-badge-primary-dot-color': color.badge.primary.dot,
|
|
60
64
|
'--card-badge-primary-fg-color': color.badge.primary.fg,
|
|
61
65
|
'--card-badge-primary-icon-color': color.badge.primary.icon,
|
|
66
|
+
'--card-badge-suggest-bg-color': color.badge.suggest?.bg,
|
|
67
|
+
'--card-badge-suggest-dot-color': color.badge.suggest?.dot,
|
|
68
|
+
'--card-badge-suggest-fg-color': color.badge.suggest?.fg,
|
|
69
|
+
'--card-badge-suggest-icon-color': color.badge.suggest?.icon,
|
|
62
70
|
'--card-badge-positive-bg-color': color.badge.positive.bg,
|
|
63
71
|
'--card-badge-positive-dot-color': color.badge.positive.dot,
|
|
64
72
|
'--card-badge-positive-fg-color': color.badge.positive.fg,
|
|
@@ -71,14 +79,6 @@ export function _cardColorStyle(
|
|
|
71
79
|
'--card-badge-critical-dot-color': color.badge.critical.dot,
|
|
72
80
|
'--card-badge-critical-fg-color': color.badge.critical.fg,
|
|
73
81
|
'--card-badge-critical-icon-color': color.badge.critical.icon,
|
|
74
|
-
'--card-badge-prospect-bg-color': color.badge.prospect.bg,
|
|
75
|
-
'--card-badge-prospect-dot-color': color.badge.prospect.dot,
|
|
76
|
-
'--card-badge-prospect-fg-color': color.badge.prospect.fg,
|
|
77
|
-
'--card-badge-prospect-icon-color': color.badge.prospect.icon,
|
|
78
|
-
'--card-badge-explore-bg-color': color.badge.explore.bg,
|
|
79
|
-
'--card-badge-explore-dot-color': color.badge.explore.dot,
|
|
80
|
-
'--card-badge-explore-fg-color': color.badge.explore.fg,
|
|
81
|
-
'--card-badge-explore-icon-color': color.badge.explore.icon,
|
|
82
82
|
|
|
83
83
|
'--card-code-bg-color': color.code.bg,
|
|
84
84
|
'--card-code-fg-color': color.code.fg,
|
|
@@ -16,8 +16,6 @@ export function responsiveFlexStyle(): Array<
|
|
|
16
16
|
BASE_STYLE,
|
|
17
17
|
responsiveFlexAlignStyle,
|
|
18
18
|
responsiveFlexGapStyle,
|
|
19
|
-
responsiveFlexGapXStyle,
|
|
20
|
-
responsiveFlexGapYStyle,
|
|
21
19
|
responsiveFlexWrapStyle,
|
|
22
20
|
responsiveFlexJustifyStyle,
|
|
23
21
|
responsiveFlexDirectionStyle,
|
|
@@ -42,22 +40,6 @@ function responsiveFlexGapStyle(props: ResponsiveFlexStyleProps & ThemeProps) {
|
|
|
42
40
|
}))
|
|
43
41
|
}
|
|
44
42
|
|
|
45
|
-
function responsiveFlexGapXStyle(props: ResponsiveFlexStyleProps & ThemeProps) {
|
|
46
|
-
const {media, space} = getTheme_v2(props.theme)
|
|
47
|
-
|
|
48
|
-
return _responsive(media, props.$gapX, (gapX) => ({
|
|
49
|
-
columnGap: gapX ? rem(space[gapX]) : undefined,
|
|
50
|
-
}))
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function responsiveFlexGapYStyle(props: ResponsiveFlexStyleProps & ThemeProps) {
|
|
54
|
-
const {media, space} = getTheme_v2(props.theme)
|
|
55
|
-
|
|
56
|
-
return _responsive(media, props.$gapY, (gapY) => ({
|
|
57
|
-
rowGap: gapY ? rem(space[gapY]) : undefined,
|
|
58
|
-
}))
|
|
59
|
-
}
|
|
60
|
-
|
|
61
43
|
export function responsiveFlexWrapStyle(props: ResponsiveFlexStyleProps & ThemeProps): CSSObject[] {
|
|
62
44
|
const {media} = getTheme_v2(props.theme)
|
|
63
45
|
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
-
|
|
3
1
|
import {
|
|
4
2
|
ThemeColorButtonTone_v2,
|
|
5
3
|
ThemeColorCard_v2,
|
|
@@ -23,7 +21,7 @@ import {Root} from './Root'
|
|
|
23
21
|
|
|
24
22
|
const theme = buildTheme()
|
|
25
23
|
|
|
26
|
-
export default function BuildStory(): ReactElement {
|
|
24
|
+
export default function BuildStory(): ReactElement<any> {
|
|
27
25
|
return (
|
|
28
26
|
<Root>
|
|
29
27
|
<div
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
-
|
|
3
1
|
import {CropIcon} from '@sanity/icons'
|
|
4
2
|
import {
|
|
5
3
|
THEME_COLOR_BUTTON_MODES,
|
|
@@ -12,7 +10,7 @@ import {
|
|
|
12
10
|
ThemeColorState_v2,
|
|
13
11
|
} from '@sanity/ui/theme'
|
|
14
12
|
import {useBoolean, useSelect} from '@sanity/ui-workshop'
|
|
15
|
-
import {CSSProperties
|
|
13
|
+
import {CSSProperties} from 'react'
|
|
16
14
|
import {Badge, Box, Flex, KBD, Stack, Text} from '../../../primitives'
|
|
17
15
|
import {useRootTheme} from '../../useRootTheme'
|
|
18
16
|
|
|
@@ -50,16 +48,13 @@ export default function DebugStory() {
|
|
|
50
48
|
const button = useBoolean('Button', false, 'Props') || false
|
|
51
49
|
const selectable = useBoolean('Selectable', false, 'Props') || false
|
|
52
50
|
|
|
53
|
-
const features: Features =
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}),
|
|
61
|
-
[base, button, scheme, selectable, tone],
|
|
62
|
-
)
|
|
51
|
+
const features: Features = {
|
|
52
|
+
base,
|
|
53
|
+
button,
|
|
54
|
+
schemes: scheme == 'all' ? ['light', 'dark'] : [scheme],
|
|
55
|
+
selectable,
|
|
56
|
+
tones: tone == 'all' ? ['transparent', 'default'] : [tone],
|
|
57
|
+
}
|
|
63
58
|
|
|
64
59
|
return (
|
|
65
60
|
<Flex>
|
|
@@ -352,11 +347,21 @@ function getStateVars(state: ThemeColorState_v2) {
|
|
|
352
347
|
'--card-badge-default-fg-color': state.badge.default.fg,
|
|
353
348
|
'--card-badge-default-icon-color': state.badge.default.icon,
|
|
354
349
|
|
|
350
|
+
'--card-badge-neutral-bg-color': state.badge.neutral.bg,
|
|
351
|
+
'--card-badge-neutral-dot-color': state.badge.neutral.dot,
|
|
352
|
+
'--card-badge-neutral-fg-color': state.badge.neutral.fg,
|
|
353
|
+
'--card-badge-neutral-icon-color': state.badge.neutral.icon,
|
|
354
|
+
|
|
355
355
|
'--card-badge-primary-bg-color': state.badge.primary.bg,
|
|
356
356
|
'--card-badge-primary-dot-color': state.badge.primary.dot,
|
|
357
357
|
'--card-badge-primary-fg-color': state.badge.primary.fg,
|
|
358
358
|
'--card-badge-primary-icon-color': state.badge.primary.icon,
|
|
359
359
|
|
|
360
|
+
'--card-badge-suggest-bg-color': state.badge.suggest.bg,
|
|
361
|
+
'--card-badge-suggest-dot-color': state.badge.suggest.dot,
|
|
362
|
+
'--card-badge-suggest-fg-color': state.badge.suggest.fg,
|
|
363
|
+
'--card-badge-suggest-icon-color': state.badge.suggest.icon,
|
|
364
|
+
|
|
360
365
|
'--card-badge-positive-bg-color': state.badge.positive.bg,
|
|
361
366
|
'--card-badge-positive-dot-color': state.badge.positive.dot,
|
|
362
367
|
'--card-badge-positive-fg-color': state.badge.positive.fg,
|
|
@@ -14,7 +14,7 @@ export interface ThemeColorProviderProps {
|
|
|
14
14
|
/**
|
|
15
15
|
* @public
|
|
16
16
|
*/
|
|
17
|
-
export function ThemeColorProvider(props: ThemeColorProviderProps): React.ReactElement {
|
|
17
|
+
export function ThemeColorProvider(props: ThemeColorProviderProps): React.ReactElement<any> {
|
|
18
18
|
const {children, scheme, tone} = props
|
|
19
19
|
const root = useRootTheme()
|
|
20
20
|
|
|
@@ -23,14 +23,12 @@ export interface ThemeProviderProps {
|
|
|
23
23
|
/**
|
|
24
24
|
* @public
|
|
25
25
|
*/
|
|
26
|
-
export function ThemeProvider(props: ThemeProviderProps): React.ReactElement {
|
|
26
|
+
export function ThemeProvider(props: ThemeProviderProps): React.ReactElement<any> {
|
|
27
27
|
const parentTheme = useContext(ThemeContext)
|
|
28
|
-
const {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
tone = parentTheme?.tone || 'default',
|
|
33
|
-
} = props
|
|
28
|
+
const {children} = props
|
|
29
|
+
const scheme = props.scheme ?? (parentTheme?.scheme || 'light')
|
|
30
|
+
const rootTheme = props.theme ?? (parentTheme?.theme || null)
|
|
31
|
+
const tone = props.tone ?? (parentTheme?.tone || 'default')
|
|
34
32
|
|
|
35
33
|
const themeContext: ThemeContextValue | null = useMemo(() => {
|
|
36
34
|
if (!rootTheme) return null
|
|
@@ -68,7 +68,7 @@ export const Arrow = forwardRef(function Arrow(
|
|
|
68
68
|
'width' | 'height'
|
|
69
69
|
>,
|
|
70
70
|
ref: ForwardedRef<HTMLDivElement>,
|
|
71
|
-
): ReactElement {
|
|
71
|
+
): ReactElement<any> {
|
|
72
72
|
const {width: w, height: h, radius = 0, ...restProps} = props
|
|
73
73
|
const {card} = useTheme_v2()
|
|
74
74
|
const strokeWidth = card.shadow.outline
|
|
@@ -13,7 +13,9 @@ export interface BoundaryElementProviderProps {
|
|
|
13
13
|
/**
|
|
14
14
|
* @public
|
|
15
15
|
*/
|
|
16
|
-
export function BoundaryElementProvider(
|
|
16
|
+
export function BoundaryElementProvider(
|
|
17
|
+
props: BoundaryElementProviderProps,
|
|
18
|
+
): React.ReactElement<any> {
|
|
17
19
|
const {children, element} = props
|
|
18
20
|
const value: BoundaryElementContextValue = useMemo(() => ({version: 0.0, element}), [element])
|
|
19
21
|
|