@sanity/ui 4.2.0 → 5.0.0-alpha.10
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/README.md +194 -28
- package/bin/sanity-ui.js +14 -0
- package/dist/_chunks-es/LazyRefractor.js +20 -0
- package/dist/_chunks-es/LazyRefractor.js.map +1 -0
- package/dist/cli/checks.js +148 -0
- package/dist/cli/config.js +23 -0
- package/dist/cli/detect.js +181 -0
- package/dist/cli/doctor.js +49 -0
- package/dist/cli/index.js +69 -0
- package/dist/cli/init.js +189 -0
- package/dist/cli/install.js +79 -0
- package/dist/cli/log.js +66 -0
- package/dist/cli/selfPackage.js +11 -0
- package/dist/cli/styles.js +185 -0
- package/dist/cli/test-utils.js +8 -0
- package/dist/cli/tsconfig.js +236 -0
- package/dist/cli/types.js +1 -0
- package/dist/cli/versions.js +45 -0
- package/dist/index.d.ts +1203 -1469
- package/dist/index.js +2123 -1989
- package/dist/index.js.map +1 -1
- package/dist/polyfills.d.ts +1 -0
- package/dist/polyfills.js +5 -0
- package/dist/polyfills.js.map +1 -0
- package/dist/styles.css +1 -547
- package/package.json +57 -58
- package/src/cli/checks.test.ts +38 -0
- package/src/cli/checks.ts +200 -0
- package/src/cli/config.ts +44 -0
- package/src/cli/detect.test.ts +191 -0
- package/src/cli/detect.ts +205 -0
- package/src/cli/doctor.test.ts +52 -0
- package/src/cli/doctor.ts +65 -0
- package/src/cli/index.ts +77 -0
- package/src/cli/init.ts +225 -0
- package/src/cli/install.test.ts +52 -0
- package/src/cli/install.ts +108 -0
- package/src/cli/log.ts +79 -0
- package/src/cli/selfPackage.ts +14 -0
- package/src/cli/styles.test.ts +130 -0
- package/src/cli/styles.ts +205 -0
- package/src/cli/test-utils.ts +10 -0
- package/src/cli/tsconfig.test.ts +174 -0
- package/src/cli/tsconfig.ts +282 -0
- package/src/cli/types.ts +77 -0
- package/src/cli/versions.test.ts +35 -0
- package/src/cli/versions.ts +41 -0
- package/src/components/badge/Badge.tsx +53 -0
- package/src/components/badge/badge.css +6 -0
- package/src/components/badge/badge.props.ts +31 -0
- package/src/components/box/Box.tsx +30 -0
- package/src/components/box/box.css +4 -0
- package/src/components/box/box.props.ts +29 -0
- package/src/components/button/Button.tsx +78 -0
- package/src/components/button/button.css +72 -0
- package/src/components/button/button.props.ts +122 -0
- package/src/components/card/Card.tsx +31 -0
- package/src/components/card/card.css +4 -0
- package/src/components/card/card.props.ts +58 -0
- package/src/components/checkbox/Checkbox.tsx +64 -0
- package/src/components/checkbox/checkbox.css +100 -0
- package/src/components/checkbox/checkbox.props.ts +33 -0
- package/src/components/code/Code.tsx +38 -0
- package/src/components/code/LazyRefractor.tsx +9 -0
- package/src/components/code/code.css +40 -0
- package/src/components/code/code.props.ts +44 -0
- package/src/components/container/Container.tsx +30 -0
- package/src/components/container/container.css +4 -0
- package/src/components/container/container.props.ts +28 -0
- package/src/components/dialog/Dialog.tsx +139 -0
- package/src/components/dialog/dialog.css +49 -0
- package/src/components/dialog/dialog.props.ts +45 -0
- package/src/components/divider/Divider.tsx +23 -0
- package/src/components/divider/divider.props.ts +9 -0
- package/src/components/eyebrow/Eyebrow.tsx +54 -0
- package/src/components/eyebrow/eyebrow.css +11 -0
- package/src/components/eyebrow/eyebrow.props.ts +28 -0
- package/src/components/flex/Flex.tsx +30 -0
- package/src/components/flex/flex.css +4 -0
- package/src/components/flex/flex.props.ts +33 -0
- package/src/components/grid/Grid.tsx +30 -0
- package/src/components/grid/grid.css +4 -0
- package/src/components/grid/grid.props.ts +33 -0
- package/src/components/h-stack/HStack.tsx +34 -0
- package/src/components/h-stack/hStack.props.ts +17 -0
- package/src/components/heading/Heading.tsx +54 -0
- package/src/components/heading/heading.css +9 -0
- package/src/components/heading/heading.props.ts +31 -0
- package/src/components/icon/Icon.tsx +24 -0
- package/src/components/icon/icon.css +17 -0
- package/src/components/icon/icon.props.ts +35 -0
- package/src/components/icon-button/IconButton.tsx +32 -0
- package/src/components/icon-button/iconButton.props.ts +31 -0
- package/src/components/index.css +28 -0
- package/src/components/indicator/Indicator.tsx +42 -0
- package/src/components/indicator/indicator.css +4 -0
- package/src/components/indicator/indicator.props.ts +24 -0
- package/src/components/indicator-stack/IndicatorStack.tsx +31 -0
- package/src/components/indicator-stack/indicator-stack.css +7 -0
- package/src/components/indicator-stack/indicatorStack.props.ts +15 -0
- package/src/components/inline/Inline.tsx +38 -0
- package/src/components/inline/inline.css +4 -0
- package/src/components/inline/inline.props.ts +100 -0
- package/src/components/label/Label.tsx +34 -0
- package/src/components/label/label.css +3 -0
- package/src/components/label/label.props.ts +25 -0
- package/src/components/link/Link.tsx +29 -0
- package/src/components/link/link.css +12 -0
- package/src/components/link/link.props.ts +23 -0
- package/src/components/list/List.tsx +167 -0
- package/src/components/list/list.css +25 -0
- package/src/components/list/list.props.ts +130 -0
- package/src/components/popover/Popover.tsx +85 -0
- package/src/components/popover/popover.css +21 -0
- package/src/components/popover/popover.props.ts +38 -0
- package/src/components/press-area/PressArea.tsx +29 -0
- package/src/components/press-area/press-area.css +22 -0
- package/src/components/press-area/pressArea.props.ts +16 -0
- package/src/components/radio/Radio.tsx +48 -0
- package/src/components/radio/radio.css +97 -0
- package/src/components/radio/radio.props.ts +25 -0
- package/src/components/skip-to-content/SkipToContent.tsx +35 -0
- package/src/components/skip-to-content/skip-to-content.css +9 -0
- package/src/components/skip-to-content/skipToContent.props.ts +25 -0
- package/src/components/spinner/Spinner.tsx +28 -0
- package/src/components/spinner/spinner.css +10 -0
- package/src/components/spinner/spinner.props.ts +19 -0
- package/src/components/switch/Switch.tsx +48 -0
- package/src/components/switch/switch.css +119 -0
- package/src/components/switch/switch.props.ts +25 -0
- package/src/components/text/Text.tsx +53 -0
- package/src/components/text/text.css +9 -0
- package/src/components/text/text.props.ts +28 -0
- package/src/components/tooltip/Tooltip.tsx +97 -0
- package/src/components/tooltip/tooltip.css +31 -0
- package/src/components/tooltip/tooltip.props.ts +36 -0
- package/src/components/tooltip-group/TooltipGroup.tsx +64 -0
- package/src/components/tooltip-group/tooltipGroup.props.ts +15 -0
- package/src/components/v-stack/VStack.tsx +32 -0
- package/src/components/v-stack/vStack.props.ts +17 -0
- package/src/components/visually-hidden/VisuallyHidden.tsx +29 -0
- package/src/components/visually-hidden/visually-hidden.css +9 -0
- package/src/components/visually-hidden/visuallyHidden.props.ts +23 -0
- package/src/css/classes/dynamic/flex-child.css +5 -0
- package/src/css/classes/dynamic/grid-child.css +8 -0
- package/src/css/classes/dynamic/grid-parent.css +6 -0
- package/src/css/classes/dynamic/height.css +5 -0
- package/src/css/classes/dynamic/index.css +7 -0
- package/src/css/classes/dynamic/line-clamp.css +5 -0
- package/src/css/classes/dynamic/readme.md +3 -0
- package/src/css/classes/dynamic/width.css +7 -0
- package/src/css/classes/dynamic/z-index.css +3 -0
- package/src/css/classes/generic/display.css +10 -0
- package/src/css/classes/generic/flex.css +24 -0
- package/src/css/classes/generic/grid.css +7 -0
- package/src/css/classes/generic/index.css +7 -0
- package/src/css/classes/generic/overflow.css +19 -0
- package/src/css/classes/generic/placement.css +202 -0
- package/src/css/classes/generic/position.css +7 -0
- package/src/css/classes/generic/readme.md +3 -0
- package/src/css/classes/generic/text-align.css +5 -0
- package/src/css/classes/index.css +4 -0
- package/src/css/classes/local/animation.css +4 -0
- package/src/css/classes/local/border.css +20 -0
- package/src/css/classes/local/index.css +6 -0
- package/src/css/classes/local/readme.md +3 -0
- package/src/css/classes/local/text-overflow.css +5 -0
- package/src/css/classes/local/text-trim.css +45 -0
- package/src/css/classes/local/tone.css +75 -0
- package/src/css/classes/local/top-anchor.css +4 -0
- package/src/css/classes/system/color.css +223 -0
- package/src/css/classes/system/container.css +8 -0
- package/src/css/classes/system/font-family.css +2 -0
- package/src/css/classes/system/font-weight.css +4 -0
- package/src/css/classes/system/gap.css +37 -0
- package/src/css/classes/system/index.css +10 -0
- package/src/css/classes/system/inset.css +56 -0
- package/src/css/classes/system/margin.css +148 -0
- package/src/css/classes/system/padding.css +78 -0
- package/src/css/classes/system/radius.css +10 -0
- package/src/css/classes/system/readme.md +3 -0
- package/src/css/classes/system/shadow.css +6 -0
- package/src/css/classes/system/typography.css +31 -0
- package/src/css/global/font-face.css +20 -0
- package/src/css/global/index.css +2 -0
- package/src/css/global/reset.css +76 -0
- package/src/css/tokens/index.css +3 -0
- package/src/css/tokens/opacity.css +6 -0
- package/src/css/tokens/semantic.css +25 -0
- package/src/css/tokens/surface.css +27 -0
- package/src/hooks/useIsClient.ts +10 -0
- package/src/index.css +18 -0
- package/src/index.ts +65 -0
- package/src/polyfills.ts +15 -0
- package/src/props/border.ts +51 -0
- package/src/props/flexChild.ts +29 -0
- package/src/props/flexParent.ts +47 -0
- package/src/props/gap.ts +31 -0
- package/src/props/gridChild.ts +50 -0
- package/src/props/gridParent.ts +45 -0
- package/src/props/height.ts +29 -0
- package/src/props/layout.ts +44 -0
- package/src/props/margin.ts +59 -0
- package/src/props/overflow.ts +30 -0
- package/src/props/padding.ts +59 -0
- package/src/props/placement.ts +16 -0
- package/src/props/position.ts +52 -0
- package/src/props/shadow.ts +15 -0
- package/src/props/tone.ts +15 -0
- package/src/props/typography.ts +62 -0
- package/src/props/width.ts +29 -0
- package/src/props/zIndex.ts +15 -0
- package/src/styles.css.d.ts +1 -0
- package/src/styles.css.node.js +2 -0
- package/src/styles.css.test.ts +24 -0
- package/src/types/Button.ts +8 -0
- package/src/types/Code.ts +6 -0
- package/src/types/Container.ts +3 -0
- package/src/types/Density.ts +3 -0
- package/src/types/Display.ts +11 -0
- package/src/types/Eyebrow.ts +3 -0
- package/src/types/Flex.ts +22 -0
- package/src/types/FontWeight.ts +3 -0
- package/src/types/Grid.ts +3 -0
- package/src/types/Heading.ts +6 -0
- package/src/types/Icon.ts +3 -0
- package/src/types/Interactive.ts +8 -0
- package/src/types/List.ts +2 -0
- package/src/types/Overflow.ts +3 -0
- package/src/types/Placement.ts +16 -0
- package/src/types/Position.ts +3 -0
- package/src/types/PropDef.ts +73 -0
- package/src/types/Radius.ts +3 -0
- package/src/types/Responsive.ts +10 -0
- package/src/types/Shadow.ts +3 -0
- package/src/types/Space.ts +15 -0
- package/src/types/Text.ts +3 -0
- package/src/types/TextAlign.ts +3 -0
- package/src/types/Tone.ts +3 -0
- package/src/utils/getProps.test.ts +156 -0
- package/src/utils/getProps.ts +156 -0
- package/src/utils/mergeTriggerProps.ts +66 -0
- package/src/utils/renderPortal.tsx +14 -0
- package/src/utils/suffixClassName.ts +5 -0
- package/src/version.ts +3 -0
- package/LICENSE +0 -21
- package/dist/_system-CTe2lb5l.d.ts +0 -40
- package/dist/_system-CTe2lb5l.d.ts.map +0 -1
- package/dist/arrow-BmX6qbAS.js +0 -170
- package/dist/arrow-BmX6qbAS.js.map +0 -1
- package/dist/autocomplete.d.ts +0 -140
- package/dist/autocomplete.d.ts.map +0 -1
- package/dist/autocomplete.js +0 -470
- package/dist/autocomplete.js.map +0 -1
- package/dist/breadcrumbs.d.ts +0 -18
- package/dist/breadcrumbs.d.ts.map +0 -1
- package/dist/breadcrumbs.js +0 -119
- package/dist/breadcrumbs.js.map +0 -1
- package/dist/button-BNyKSDyA.js +0 -180
- package/dist/button-BNyKSDyA.js.map +0 -1
- package/dist/button-dnqMFkWg.d.ts +0 -76
- package/dist/button-dnqMFkWg.d.ts.map +0 -1
- package/dist/card-C0a0wQTc.d.ts +0 -7
- package/dist/card-C0a0wQTc.d.ts.map +0 -1
- package/dist/code.d.ts +0 -20
- package/dist/code.d.ts.map +0 -1
- package/dist/code.js +0 -90
- package/dist/code.js.map +0 -1
- package/dist/codeFontStyle-84SMhFtI.js +0 -11
- package/dist/codeFontStyle-84SMhFtI.js.map +0 -1
- package/dist/component-DVlwaWB-.d.ts +0 -25
- package/dist/component-DVlwaWB-.d.ts.map +0 -1
- package/dist/element-BYgCE_iK.js +0 -51
- package/dist/element-BYgCE_iK.js.map +0 -1
- package/dist/factory-BzXTX8_Q.js +0 -3056
- package/dist/factory-BzXTX8_Q.js.map +0 -1
- package/dist/flex-DmbDG2ks.js +0 -76
- package/dist/flex-DmbDG2ks.js.map +0 -1
- package/dist/font-EtfxKPUz.d.ts +0 -49
- package/dist/font-EtfxKPUz.d.ts.map +0 -1
- package/dist/getElementRef-Jw7gY0eV.js +0 -102
- package/dist/getElementRef-Jw7gY0eV.js.map +0 -1
- package/dist/getScopedTheme-C-sZsyAz.js +0 -267
- package/dist/getScopedTheme-C-sZsyAz.js.map +0 -1
- package/dist/getTheme_v2-y09KqtEb.js +0 -487
- package/dist/getTheme_v2-y09KqtEb.js.map +0 -1
- package/dist/grid-6JSgMj1O.js +0 -115
- package/dist/grid-6JSgMj1O.js.map +0 -1
- package/dist/helpers-C8xxXAQC.js +0 -63
- package/dist/helpers-C8xxXAQC.js.map +0 -1
- package/dist/hotkeys-CaHsQlsO.js +0 -168
- package/dist/hotkeys-CaHsQlsO.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/layer-Bl5R3uNR.js +0 -61
- package/dist/layer-Bl5R3uNR.js.map +0 -1
- package/dist/layer-ChlP9Ik6.d.ts +0 -242
- package/dist/layer-ChlP9Ik6.d.ts.map +0 -1
- package/dist/menu.d.ts +0 -146
- package/dist/menu.d.ts.map +0 -1
- package/dist/menu.js +0 -626
- package/dist/menu.js.map +0 -1
- package/dist/popover-B7-28L8y.js +0 -408
- package/dist/popover-B7-28L8y.js.map +0 -1
- package/dist/popover-CMlQeKn0.d.ts +0 -96
- package/dist/popover-CMlQeKn0.d.ts.map +0 -1
- package/dist/popover.d.ts +0 -2
- package/dist/popover.js +0 -3
- package/dist/refractor-CC48DwHi.js +0 -20
- package/dist/refractor-CC48DwHi.js.map +0 -1
- package/dist/responsiveFont-CilwaORG.js +0 -55
- package/dist/responsiveFont-CilwaORG.js.map +0 -1
- package/dist/rgba-BSYaEUW6.d.ts +0 -846
- package/dist/rgba-BSYaEUW6.d.ts.map +0 -1
- package/dist/selectable-B0GUIL74.d.ts +0 -7
- package/dist/selectable-B0GUIL74.d.ts.map +0 -1
- package/dist/stack-rsNFPq2-.js +0 -112
- package/dist/stack-rsNFPq2-.js.map +0 -1
- package/dist/styles-css.d.ts +0 -2
- package/dist/styles-css.js +0 -4
- package/dist/textInput-pSfQjkmx.js +0 -313
- package/dist/textInput-pSfQjkmx.js.map +0 -1
- package/dist/theme.d.ts +0 -280
- package/dist/theme.d.ts.map +0 -1
- package/dist/theme.js +0 -55
- package/dist/theme.js.map +0 -1
- package/dist/toast.d.ts +0 -73
- package/dist/toast.d.ts.map +0 -1
- package/dist/toast.js +0 -302
- package/dist/toast.js.map +0 -1
- package/dist/tooltip.d.ts +0 -88
- package/dist/tooltip.d.ts.map +0 -1
- package/dist/tooltip.js +0 -435
- package/dist/tooltip.js.map +0 -1
- package/dist/useClickOutsideEvent-wGLGWBZN.js +0 -36
- package/dist/useClickOutsideEvent-wGLGWBZN.js.map +0 -1
- package/dist/useElementSize-BJvbGHq8.js +0 -51
- package/dist/useElementSize-BJvbGHq8.js.map +0 -1
- package/dist/useLayer-D1usxIE0.js +0 -712
- package/dist/useLayer-D1usxIE0.js.map +0 -1
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import {type PlacementProps, placementProps} from '../../props/placement'
|
|
2
|
+
import {type PropDef} from '../../types/PropDef'
|
|
3
|
+
|
|
4
|
+
/** @beta */
|
|
5
|
+
export interface TooltipProps
|
|
6
|
+
extends Omit<React.ComponentProps<'div'>, 'children' | 'content'>, PlacementProps {
|
|
7
|
+
/**
|
|
8
|
+
* Shared anchor identifier.
|
|
9
|
+
*/
|
|
10
|
+
anchorName?: React.ReactNode
|
|
11
|
+
/**
|
|
12
|
+
* The trigger element.
|
|
13
|
+
*/
|
|
14
|
+
children: React.ReactElement<Record<string, unknown>>
|
|
15
|
+
/**
|
|
16
|
+
* The tooltip label.
|
|
17
|
+
*/
|
|
18
|
+
content?: React.ReactNode
|
|
19
|
+
/**
|
|
20
|
+
* Renders the label into `document.body` through a React portal instead of inline.
|
|
21
|
+
*/
|
|
22
|
+
portal?: boolean
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const tooltipProps: Record<string, PropDef> = {
|
|
26
|
+
anchorName: {
|
|
27
|
+
type: 'string',
|
|
28
|
+
},
|
|
29
|
+
content: {
|
|
30
|
+
type: 'string',
|
|
31
|
+
},
|
|
32
|
+
portal: {
|
|
33
|
+
type: 'boolean',
|
|
34
|
+
},
|
|
35
|
+
...placementProps,
|
|
36
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import clsx from 'clsx'
|
|
2
|
+
import {type ComponentPropsWithRef, type ElementType, useRef, useState} from 'react'
|
|
3
|
+
|
|
4
|
+
import {getProps} from '../../utils/getProps'
|
|
5
|
+
import {suffixClassName} from '../../utils/suffixClassName'
|
|
6
|
+
import {type TooltipGroupProps, tooltipGroupProps} from './tooltipGroup.props'
|
|
7
|
+
|
|
8
|
+
const tooltipGroupClassName = suffixClassName('sui-TooltipGroup')
|
|
9
|
+
|
|
10
|
+
/** @public */
|
|
11
|
+
export function TooltipGroup<T extends ElementType = 'div'>(
|
|
12
|
+
props: TooltipGroupProps<T> & Omit<ComponentPropsWithRef<T>, keyof TooltipGroupProps<T>>,
|
|
13
|
+
) {
|
|
14
|
+
const {as, children, className, style, ...rest} = getProps(props, tooltipGroupProps)
|
|
15
|
+
const Component = as || 'div'
|
|
16
|
+
const ref = useRef<HTMLElement>(null)
|
|
17
|
+
const [isActive, setIsActive] = useState(false)
|
|
18
|
+
|
|
19
|
+
const handleTransitionEnd = (e: TransitionEvent) => {
|
|
20
|
+
const tooltip = (e.target as Element).closest('[data-ui="Tooltip"]')
|
|
21
|
+
|
|
22
|
+
if (!tooltip) {
|
|
23
|
+
return
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (e.propertyName === 'opacity' && window.getComputedStyle(tooltip).opacity !== '0') {
|
|
27
|
+
setIsActive(true)
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const handleMouseLeave = () => {
|
|
32
|
+
setIsActive(false)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const handleBlur = (e: FocusEvent) => {
|
|
36
|
+
if (ref.current && ref.current.contains(e.relatedTarget as Node)) {
|
|
37
|
+
return
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
setIsActive(false)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<Component
|
|
45
|
+
className={clsx(tooltipGroupClassName, className)}
|
|
46
|
+
style={{
|
|
47
|
+
...style,
|
|
48
|
+
...(isActive && {
|
|
49
|
+
'--tooltip-delay-group': '0ms',
|
|
50
|
+
}),
|
|
51
|
+
}}
|
|
52
|
+
data-ui="TooltipGroup"
|
|
53
|
+
ref={ref}
|
|
54
|
+
onTransitionEnd={handleTransitionEnd}
|
|
55
|
+
onMouseLeave={handleMouseLeave}
|
|
56
|
+
onBlur={handleBlur}
|
|
57
|
+
{...rest}
|
|
58
|
+
>
|
|
59
|
+
{children}
|
|
60
|
+
</Component>
|
|
61
|
+
)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export type {TooltipGroupProps}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {type PropDef} from '../../types/PropDef'
|
|
2
|
+
|
|
3
|
+
/** @public */
|
|
4
|
+
export interface TooltipGroupProps<T extends React.ElementType = 'div'> {
|
|
5
|
+
/**
|
|
6
|
+
* HTML element to render.
|
|
7
|
+
*/
|
|
8
|
+
as?: T
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const tooltipGroupProps: Record<string, PropDef> = {
|
|
12
|
+
as: {
|
|
13
|
+
type: 'string',
|
|
14
|
+
},
|
|
15
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import clsx from 'clsx'
|
|
2
|
+
import type {ComponentPropsWithRef, ElementType} from 'react'
|
|
3
|
+
|
|
4
|
+
import {getProps} from '../../utils/getProps'
|
|
5
|
+
import {suffixClassName} from '../../utils/suffixClassName'
|
|
6
|
+
import {Flex} from '../flex/Flex'
|
|
7
|
+
import {type VStackProps, vStackProps} from './vStack.props'
|
|
8
|
+
|
|
9
|
+
const vStackClassName = suffixClassName('sui-VStack')
|
|
10
|
+
|
|
11
|
+
/** @public */
|
|
12
|
+
export function VStack<T extends ElementType = 'div'>(
|
|
13
|
+
props: VStackProps<T> & Omit<ComponentPropsWithRef<T>, keyof VStackProps<T>>,
|
|
14
|
+
) {
|
|
15
|
+
const {as, children, className, style, ...rest} = getProps(props, vStackProps)
|
|
16
|
+
const Component = as || 'div'
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<Flex
|
|
20
|
+
as={Component}
|
|
21
|
+
className={clsx(vStackClassName, className)}
|
|
22
|
+
style={style}
|
|
23
|
+
data-ui="VStack"
|
|
24
|
+
flexDirection="column"
|
|
25
|
+
{...rest}
|
|
26
|
+
>
|
|
27
|
+
{children}
|
|
28
|
+
</Flex>
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export type {VStackProps}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import {type GapProps, gapProps} from '../../props/gap'
|
|
2
|
+
import {type PropDef} from '../../types/PropDef'
|
|
3
|
+
|
|
4
|
+
/** @public */
|
|
5
|
+
export interface VStackProps<T extends React.ElementType = 'div'> extends Pick<GapProps, 'gap'> {
|
|
6
|
+
/**
|
|
7
|
+
* HTML element or component to render.
|
|
8
|
+
*/
|
|
9
|
+
as?: T
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const vStackProps: Record<string, PropDef> = {
|
|
13
|
+
as: {
|
|
14
|
+
type: 'string',
|
|
15
|
+
},
|
|
16
|
+
gap: gapProps['gap'] as PropDef,
|
|
17
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import clsx from 'clsx'
|
|
2
|
+
import type {ComponentPropsWithRef, ElementType} from 'react'
|
|
3
|
+
|
|
4
|
+
import {getProps} from '../../utils/getProps'
|
|
5
|
+
import {suffixClassName} from '../../utils/suffixClassName'
|
|
6
|
+
import {type VisuallyHiddenProps, visuallyHiddenProps} from './visuallyHidden.props'
|
|
7
|
+
|
|
8
|
+
const visuallyHiddenClassName = suffixClassName('sui-VisuallyHidden')
|
|
9
|
+
|
|
10
|
+
/** @public */
|
|
11
|
+
export function VisuallyHidden<T extends ElementType = 'span'>(
|
|
12
|
+
props: VisuallyHiddenProps<T> & Omit<ComponentPropsWithRef<T>, keyof VisuallyHiddenProps<T>>,
|
|
13
|
+
) {
|
|
14
|
+
const {as, children, className, style, ...rest} = getProps(props, visuallyHiddenProps)
|
|
15
|
+
const Component = as || 'span'
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<Component
|
|
19
|
+
className={clsx(visuallyHiddenClassName, className)}
|
|
20
|
+
style={style}
|
|
21
|
+
data-ui="VisuallyHidden"
|
|
22
|
+
{...rest}
|
|
23
|
+
>
|
|
24
|
+
{children}
|
|
25
|
+
</Component>
|
|
26
|
+
)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export type {VisuallyHiddenProps}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {type PropDef} from '../../types/PropDef'
|
|
2
|
+
|
|
3
|
+
/** @public */
|
|
4
|
+
export interface VisuallyHiddenProps<T extends React.ElementType = 'span'> {
|
|
5
|
+
/**
|
|
6
|
+
* HTML element to render.
|
|
7
|
+
*/
|
|
8
|
+
as?: T
|
|
9
|
+
/**
|
|
10
|
+
* If true, the element becomes visible on `:focus-visible`.
|
|
11
|
+
*/
|
|
12
|
+
visibleOnFocus?: boolean
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const visuallyHiddenProps: Record<string, PropDef> = {
|
|
16
|
+
as: {
|
|
17
|
+
type: 'string',
|
|
18
|
+
},
|
|
19
|
+
visibleOnFocus: {
|
|
20
|
+
type: 'boolean',
|
|
21
|
+
className: 'sui-visually-hidden-visible',
|
|
22
|
+
},
|
|
23
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
@breakpoints {
|
|
2
|
+
.sui-grid-column { grid-column: var(--grid-column); }
|
|
3
|
+
.sui-grid-column-start { grid-column-start: var(--grid-column-start); }
|
|
4
|
+
.sui-grid-column-end { grid-column-end: var(--grid-column-end); }
|
|
5
|
+
.sui-grid-row { grid-row: var(--grid-row); }
|
|
6
|
+
.sui-grid-row-start { grid-row-start: var(--grid-row-start); }
|
|
7
|
+
.sui-grid-row-end { grid-row-end: var(--grid-row-end); }
|
|
8
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
@breakpoints {
|
|
2
|
+
.sui-grid-auto-columns { grid-auto-columns: var(--grid-auto-columns); }
|
|
3
|
+
.sui-grid-auto-rows { grid-auto-rows: var(--grid-auto-rows); }
|
|
4
|
+
.sui-grid-template-columns { grid-template-columns: var(--grid-template-columns); }
|
|
5
|
+
.sui-grid-template-rows { grid-template-rows: var(--grid-template-rows); }
|
|
6
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
@breakpoints {
|
|
2
|
+
.sui-display-block:not([hidden]) { display: block; }
|
|
3
|
+
.sui-display-inline-block:not([hidden]) { display: inline-block; }
|
|
4
|
+
.sui-display-inline:not([hidden]) { display: inline; }
|
|
5
|
+
.sui-display-flex:not([hidden]) { display: flex; }
|
|
6
|
+
.sui-display-inline-flex:not([hidden]) { display: inline-flex; }
|
|
7
|
+
.sui-display-grid:not([hidden]) { display: grid; }
|
|
8
|
+
.sui-display-inline-grid:not([hidden]) { display: inline-grid; }
|
|
9
|
+
.sui-display-none:not([hidden]) { display: none; }
|
|
10
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
@breakpoints {
|
|
2
|
+
.sui-align-items-flex-start { align-items: flex-start; }
|
|
3
|
+
.sui-align-items-center { align-items: center; }
|
|
4
|
+
.sui-align-items-flex-end { align-items: flex-end; }
|
|
5
|
+
.sui-align-items-baseline { align-items: baseline; }
|
|
6
|
+
.sui-align-items-stretch { align-items: stretch; }
|
|
7
|
+
|
|
8
|
+
.sui-justify-content-flex-start { justify-content: flex-start; }
|
|
9
|
+
.sui-justify-content-center { justify-content: center; }
|
|
10
|
+
.sui-justify-content-flex-end { justify-content: flex-end; }
|
|
11
|
+
.sui-justify-content-space-between { justify-content: space-between; }
|
|
12
|
+
.sui-justify-content-space-around { justify-content: space-around; }
|
|
13
|
+
.sui-justify-content-space-evenly { justify-content: space-evenly; }
|
|
14
|
+
.sui-justify-content-stretch { justify-content: stretch; }
|
|
15
|
+
|
|
16
|
+
.sui-flex-direction-row { flex-direction: row; }
|
|
17
|
+
.sui-flex-direction-row-reverse { flex-direction: row-reverse; }
|
|
18
|
+
.sui-flex-direction-column { flex-direction: column; }
|
|
19
|
+
.sui-flex-direction-column-reverse { flex-direction: column-reverse; }
|
|
20
|
+
|
|
21
|
+
.sui-flex-wrap { flex-wrap: wrap; }
|
|
22
|
+
.sui-flex-nowrap { flex-wrap: nowrap; }
|
|
23
|
+
.sui-flex-wrap-reverse { flex-wrap: wrap-reverse; }
|
|
24
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
@breakpoints {
|
|
2
|
+
.sui-grid-auto-flow-row { grid-auto-flow: row; }
|
|
3
|
+
.sui-grid-auto-flow-row-dense { grid-auto-flow: row dense; }
|
|
4
|
+
.sui-grid-auto-flow-column { grid-auto-flow: column; }
|
|
5
|
+
.sui-grid-auto-flow-column-dense { grid-auto-flow: column dense; }
|
|
6
|
+
.sui-grid-auto-flow-dense { grid-auto-flow: dense; }
|
|
7
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
@breakpoints {
|
|
2
|
+
.sui-overflow-visible { overflow: visible; }
|
|
3
|
+
.sui-overflow-scroll { overflow: scroll; }
|
|
4
|
+
.sui-overflow-clip { overflow: clip; }
|
|
5
|
+
.sui-overflow-hidden { overflow: hidden; }
|
|
6
|
+
.sui-overflow-auto { overflow: auto; }
|
|
7
|
+
|
|
8
|
+
.sui-overflow-x-visible { overflow-x: visible; }
|
|
9
|
+
.sui-overflow-x-scroll { overflow-x: scroll; }
|
|
10
|
+
.sui-overflow-x-clip { overflow-x: clip; }
|
|
11
|
+
.sui-overflow-x-hidden { overflow-x: hidden; }
|
|
12
|
+
.sui-overflow-x-auto { overflow-x: auto; }
|
|
13
|
+
|
|
14
|
+
.sui-overflow-y-visible { overflow-y: visible; }
|
|
15
|
+
.sui-overflow-y-scroll { overflow-y: scroll; }
|
|
16
|
+
.sui-overflow-y-clip { overflow-y: clip; }
|
|
17
|
+
.sui-overflow-y-hidden { overflow-y: hidden; }
|
|
18
|
+
.sui-overflow-y-auto { overflow-y: auto; }
|
|
19
|
+
}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
[class*='placement-'] {
|
|
2
|
+
inset: auto;
|
|
3
|
+
margin: 0;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
@position-try --top-center {
|
|
7
|
+
top: auto;
|
|
8
|
+
right: auto;
|
|
9
|
+
bottom: anchor(top);
|
|
10
|
+
left: anchor(center);
|
|
11
|
+
translate: -50% 0;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
@position-try --top-start {
|
|
15
|
+
top: auto;
|
|
16
|
+
right: auto;
|
|
17
|
+
bottom: anchor(top);
|
|
18
|
+
left: anchor(left);
|
|
19
|
+
translate: none;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
@position-try --top-end {
|
|
23
|
+
top: auto;
|
|
24
|
+
left: auto;
|
|
25
|
+
bottom: anchor(top);
|
|
26
|
+
right: anchor(right);
|
|
27
|
+
translate: none;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@position-try --bottom-center {
|
|
31
|
+
bottom: auto;
|
|
32
|
+
right: auto;
|
|
33
|
+
top: anchor(bottom);
|
|
34
|
+
left: anchor(center);
|
|
35
|
+
translate: -50% 0;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
@position-try --bottom-start {
|
|
39
|
+
bottom: auto;
|
|
40
|
+
right: auto;
|
|
41
|
+
top: anchor(bottom);
|
|
42
|
+
left: anchor(left);
|
|
43
|
+
translate: none;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
@position-try --bottom-end {
|
|
47
|
+
bottom: auto;
|
|
48
|
+
left: auto;
|
|
49
|
+
top: anchor(bottom);
|
|
50
|
+
right: anchor(right);
|
|
51
|
+
translate: none;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
@position-try --right-center {
|
|
55
|
+
right: auto;
|
|
56
|
+
bottom: auto;
|
|
57
|
+
left: anchor(right);
|
|
58
|
+
top: anchor(center);
|
|
59
|
+
translate: 0 -50%;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
@position-try --right-start {
|
|
63
|
+
right: auto;
|
|
64
|
+
bottom: auto;
|
|
65
|
+
left: anchor(right);
|
|
66
|
+
top: anchor(top);
|
|
67
|
+
translate: none;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
@position-try --right-end {
|
|
71
|
+
right: auto;
|
|
72
|
+
top: auto;
|
|
73
|
+
left: anchor(right);
|
|
74
|
+
bottom: anchor(bottom);
|
|
75
|
+
translate: none;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
@position-try --left-center {
|
|
79
|
+
left: auto;
|
|
80
|
+
bottom: auto;
|
|
81
|
+
right: anchor(left);
|
|
82
|
+
top: anchor(center);
|
|
83
|
+
translate: 0 -50%;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
@position-try --left-start {
|
|
87
|
+
left: auto;
|
|
88
|
+
bottom: auto;
|
|
89
|
+
right: anchor(left);
|
|
90
|
+
top: anchor(top);
|
|
91
|
+
translate: none;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
@position-try --left-end {
|
|
95
|
+
left: auto;
|
|
96
|
+
top: auto;
|
|
97
|
+
right: anchor(left);
|
|
98
|
+
bottom: anchor(bottom);
|
|
99
|
+
translate: none;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.sui-placement-bottom {
|
|
103
|
+
top: anchor(bottom);
|
|
104
|
+
left: anchor(center);
|
|
105
|
+
translate: -50% 0;
|
|
106
|
+
position-try-fallbacks: --top-center;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.sui-placement-bottom-start {
|
|
110
|
+
top: anchor(bottom);
|
|
111
|
+
left: anchor(left);
|
|
112
|
+
position-try-fallbacks: --top-start;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.sui-placement-bottom-end {
|
|
116
|
+
top: anchor(bottom);
|
|
117
|
+
right: anchor(right);
|
|
118
|
+
position-try-fallbacks: --top-end;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.sui-placement-top {
|
|
122
|
+
bottom: anchor(top);
|
|
123
|
+
left: anchor(center);
|
|
124
|
+
translate: -50% 0;
|
|
125
|
+
position-try-fallbacks: --bottom-center;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.sui-placement-top-start {
|
|
129
|
+
bottom: anchor(top);
|
|
130
|
+
left: anchor(left);
|
|
131
|
+
position-try-fallbacks: --bottom-start;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.sui-placement-top-end {
|
|
135
|
+
bottom: anchor(top);
|
|
136
|
+
right: anchor(right);
|
|
137
|
+
position-try-fallbacks: --bottom-end;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.sui-placement-left {
|
|
141
|
+
right: anchor(left);
|
|
142
|
+
top: anchor(center);
|
|
143
|
+
translate: 0 -50%;
|
|
144
|
+
position-try-fallbacks: --right-center;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.sui-placement-left-start {
|
|
148
|
+
right: anchor(left);
|
|
149
|
+
top: anchor(top);
|
|
150
|
+
position-try-fallbacks: --right-start;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
.sui-placement-left-end {
|
|
154
|
+
right: anchor(left);
|
|
155
|
+
bottom: anchor(bottom);
|
|
156
|
+
position-try-fallbacks: --right-end;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.sui-placement-right {
|
|
160
|
+
left: anchor(right);
|
|
161
|
+
top: anchor(center);
|
|
162
|
+
translate: 0 -50%;
|
|
163
|
+
position-try-fallbacks: --left-center;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.sui-placement-right-start {
|
|
167
|
+
left: anchor(right);
|
|
168
|
+
top: anchor(top);
|
|
169
|
+
position-try-fallbacks: --left-start;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
.sui-placement-right-end {
|
|
173
|
+
left: anchor(right);
|
|
174
|
+
bottom: anchor(bottom);
|
|
175
|
+
position-try-fallbacks: --left-end;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
[class*="placement-bottom"],
|
|
179
|
+
[class*="placement-top"] {
|
|
180
|
+
margin-block: var(--space-1);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
[class*="placement-left"],
|
|
184
|
+
[class*="placement-right"] {
|
|
185
|
+
margin-inline: var(--space-1);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
[class*="placement-bottom"] {
|
|
189
|
+
transform-origin: center top;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
[class*="placement-top"] {
|
|
193
|
+
transform-origin: center bottom;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
[class*="placement-left"] {
|
|
197
|
+
transform-origin: right center;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
[class*="placement-right"] {
|
|
201
|
+
transform-origin: left center;
|
|
202
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
[class*='sui-border'] {
|
|
2
|
+
border-color: var(--separator-low, light-dark(var(--gray-200), var(--gray-800)));
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
@breakpoints {
|
|
6
|
+
.sui-border { border-width: 1px; border-style: solid; }
|
|
7
|
+
.sui-border-none { border-style: none; }
|
|
8
|
+
|
|
9
|
+
.sui-border-top { border-top-width: 1px; border-top-style: solid; }
|
|
10
|
+
.sui-border-top-none { border-top-style: none; }
|
|
11
|
+
|
|
12
|
+
.sui-border-right { border-right-width: 1px; border-right-style: solid; }
|
|
13
|
+
.sui-border-right-none { border-right-style: none; }
|
|
14
|
+
|
|
15
|
+
.sui-border-bottom { border-bottom-width: 1px; border-bottom-style: solid; }
|
|
16
|
+
.sui-border-bottom-none { border-bottom-style: none; }
|
|
17
|
+
|
|
18
|
+
.sui-border-left { border-left-width: 1px; border-left-style: solid; }
|
|
19
|
+
.sui-border-left-none { border-left-style: none; }
|
|
20
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
# Local classes
|
|
2
|
+
|
|
3
|
+
Local classes apply custom properties defined locally to the component library. They do not apply custom properties defined at the design system level (those that are imported from our design tokens library). They may additionally apply CSS keyword values or other values, but the emphasis is the application of locally defined tokens.
|