@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,29 @@
|
|
|
1
|
+
import {type PropDef} from '../types/PropDef'
|
|
2
|
+
import {type Responsive} from '../types/Responsive'
|
|
3
|
+
|
|
4
|
+
export type HeightProps = {
|
|
5
|
+
/** CSS **height** property */
|
|
6
|
+
height?: Responsive<string>
|
|
7
|
+
/** CSS **min-height** property */
|
|
8
|
+
minHeight?: Responsive<string>
|
|
9
|
+
/** CSS **max-height** property */
|
|
10
|
+
maxHeight?: Responsive<string>
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const heightProps: Record<string, PropDef> = {
|
|
14
|
+
height: {
|
|
15
|
+
type: 'string',
|
|
16
|
+
className: 'height',
|
|
17
|
+
variable: '--height',
|
|
18
|
+
},
|
|
19
|
+
minHeight: {
|
|
20
|
+
type: 'string',
|
|
21
|
+
className: 'min-height',
|
|
22
|
+
variable: '--min-height',
|
|
23
|
+
},
|
|
24
|
+
maxHeight: {
|
|
25
|
+
type: 'string',
|
|
26
|
+
className: 'max-height',
|
|
27
|
+
variable: '--max-height',
|
|
28
|
+
},
|
|
29
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import {type PropDef} from '../types/PropDef'
|
|
2
|
+
import {type BorderProps, borderProps} from './border'
|
|
3
|
+
import {type FlexChildProps, flexChildProps} from './flexChild'
|
|
4
|
+
import {type GridChildProps, gridChildProps} from './gridChild'
|
|
5
|
+
import {type HeightProps, heightProps} from './height'
|
|
6
|
+
import {type MarginProps, marginProps} from './margin'
|
|
7
|
+
import {type OverflowProps, overflowProps} from './overflow'
|
|
8
|
+
import {type PaddingProps, paddingProps} from './padding'
|
|
9
|
+
import {type PositionProps, positionProps} from './position'
|
|
10
|
+
import {type ShadowProps, shadowProps} from './shadow'
|
|
11
|
+
import {type ToneProps, toneProps} from './tone'
|
|
12
|
+
import {type WidthProps, widthProps} from './width'
|
|
13
|
+
import {type ZIndexProps, zIndexProps} from './zIndex'
|
|
14
|
+
|
|
15
|
+
/** @public */
|
|
16
|
+
export interface LayoutProps
|
|
17
|
+
extends
|
|
18
|
+
ToneProps,
|
|
19
|
+
WidthProps,
|
|
20
|
+
HeightProps,
|
|
21
|
+
MarginProps,
|
|
22
|
+
BorderProps,
|
|
23
|
+
PaddingProps,
|
|
24
|
+
PositionProps,
|
|
25
|
+
OverflowProps,
|
|
26
|
+
FlexChildProps,
|
|
27
|
+
GridChildProps,
|
|
28
|
+
ZIndexProps,
|
|
29
|
+
ShadowProps {}
|
|
30
|
+
|
|
31
|
+
export const layoutProps: Record<string, PropDef> = {
|
|
32
|
+
...toneProps,
|
|
33
|
+
...widthProps,
|
|
34
|
+
...heightProps,
|
|
35
|
+
...marginProps,
|
|
36
|
+
...borderProps,
|
|
37
|
+
...paddingProps,
|
|
38
|
+
...positionProps,
|
|
39
|
+
...overflowProps,
|
|
40
|
+
...flexChildProps,
|
|
41
|
+
...gridChildProps,
|
|
42
|
+
...shadowProps,
|
|
43
|
+
...zIndexProps,
|
|
44
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import {type PropDef} from '../types/PropDef'
|
|
2
|
+
import {type Responsive} from '../types/Responsive'
|
|
3
|
+
import {SPACE_AUTO_NEGATIVE, type SpaceAutoNegative} from '../types/Space'
|
|
4
|
+
|
|
5
|
+
/** @public */
|
|
6
|
+
export type MarginProps = {
|
|
7
|
+
/** CSS **margin** property */
|
|
8
|
+
margin?: Responsive<SpaceAutoNegative>
|
|
9
|
+
/** CSS **margin-left** and **margin-right** properties */
|
|
10
|
+
marginX?: Responsive<SpaceAutoNegative>
|
|
11
|
+
/** CSS **margin-top** and **margin-bottom** properties */
|
|
12
|
+
marginY?: Responsive<SpaceAutoNegative>
|
|
13
|
+
/** CSS **margin-top** property */
|
|
14
|
+
marginTop?: Responsive<SpaceAutoNegative>
|
|
15
|
+
/** CSS **margin-right** property */
|
|
16
|
+
marginRight?: Responsive<SpaceAutoNegative>
|
|
17
|
+
/** CSS **margin-bottom** property */
|
|
18
|
+
marginBottom?: Responsive<SpaceAutoNegative>
|
|
19
|
+
/** CSS **margin-left** property */
|
|
20
|
+
marginLeft?: Responsive<SpaceAutoNegative>
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const marginProps: Record<string, PropDef> = {
|
|
24
|
+
margin: {
|
|
25
|
+
type: 'union',
|
|
26
|
+
className: 'm',
|
|
27
|
+
values: SPACE_AUTO_NEGATIVE,
|
|
28
|
+
},
|
|
29
|
+
marginX: {
|
|
30
|
+
type: 'union',
|
|
31
|
+
className: 'mx',
|
|
32
|
+
values: SPACE_AUTO_NEGATIVE,
|
|
33
|
+
},
|
|
34
|
+
marginY: {
|
|
35
|
+
type: 'union',
|
|
36
|
+
className: 'my',
|
|
37
|
+
values: SPACE_AUTO_NEGATIVE,
|
|
38
|
+
},
|
|
39
|
+
marginTop: {
|
|
40
|
+
type: 'union',
|
|
41
|
+
className: 'mt',
|
|
42
|
+
values: SPACE_AUTO_NEGATIVE,
|
|
43
|
+
},
|
|
44
|
+
marginRight: {
|
|
45
|
+
type: 'union',
|
|
46
|
+
className: 'mr',
|
|
47
|
+
values: SPACE_AUTO_NEGATIVE,
|
|
48
|
+
},
|
|
49
|
+
marginBottom: {
|
|
50
|
+
type: 'union',
|
|
51
|
+
className: 'mb',
|
|
52
|
+
values: SPACE_AUTO_NEGATIVE,
|
|
53
|
+
},
|
|
54
|
+
marginLeft: {
|
|
55
|
+
type: 'union',
|
|
56
|
+
className: 'ml',
|
|
57
|
+
values: SPACE_AUTO_NEGATIVE,
|
|
58
|
+
},
|
|
59
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import {OVERFLOW, type Overflow} from '../types/Overflow'
|
|
2
|
+
import {type PropDef} from '../types/PropDef'
|
|
3
|
+
import {type Responsive} from '../types/Responsive'
|
|
4
|
+
|
|
5
|
+
export type OverflowProps = {
|
|
6
|
+
/** CSS **overflow** property */
|
|
7
|
+
overflow?: Responsive<Overflow>
|
|
8
|
+
/** CSS **overflow-x** property */
|
|
9
|
+
overflowX?: Responsive<Overflow>
|
|
10
|
+
/** CSS **overflow-y** property */
|
|
11
|
+
overflowY?: Responsive<Overflow>
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const overflowProps: Record<string, PropDef> = {
|
|
15
|
+
overflow: {
|
|
16
|
+
type: 'union',
|
|
17
|
+
className: 'overflow',
|
|
18
|
+
values: OVERFLOW,
|
|
19
|
+
},
|
|
20
|
+
overflowX: {
|
|
21
|
+
type: 'union',
|
|
22
|
+
className: 'overflow-x',
|
|
23
|
+
values: OVERFLOW,
|
|
24
|
+
},
|
|
25
|
+
overflowY: {
|
|
26
|
+
type: 'union',
|
|
27
|
+
className: 'overflow-y',
|
|
28
|
+
values: OVERFLOW,
|
|
29
|
+
},
|
|
30
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import {type PropDef} from '../types/PropDef'
|
|
2
|
+
import {type Responsive} from '../types/Responsive'
|
|
3
|
+
import {SPACE, type Space} from '../types/Space'
|
|
4
|
+
|
|
5
|
+
/** @public */
|
|
6
|
+
export interface PaddingProps {
|
|
7
|
+
/** CSS **padding** property */
|
|
8
|
+
padding?: Responsive<Space>
|
|
9
|
+
/** CSS **padding-left** and **padding-right** properties */
|
|
10
|
+
paddingX?: Responsive<Space>
|
|
11
|
+
/** CSS **padding-top** and **padding-bottom** properties */
|
|
12
|
+
paddingY?: Responsive<Space>
|
|
13
|
+
/** CSS **padding-top** property */
|
|
14
|
+
paddingTop?: Responsive<Space>
|
|
15
|
+
/** CSS **padding-right** property */
|
|
16
|
+
paddingRight?: Responsive<Space>
|
|
17
|
+
/** CSS **padding-bottom** property */
|
|
18
|
+
paddingBottom?: Responsive<Space>
|
|
19
|
+
/** CSS **padding-left** property */
|
|
20
|
+
paddingLeft?: Responsive<Space>
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const paddingProps: Record<string, PropDef> = {
|
|
24
|
+
padding: {
|
|
25
|
+
type: 'union',
|
|
26
|
+
className: 'p',
|
|
27
|
+
values: SPACE,
|
|
28
|
+
},
|
|
29
|
+
paddingX: {
|
|
30
|
+
type: 'union',
|
|
31
|
+
className: 'px',
|
|
32
|
+
values: SPACE,
|
|
33
|
+
},
|
|
34
|
+
paddingY: {
|
|
35
|
+
type: 'union',
|
|
36
|
+
className: 'py',
|
|
37
|
+
values: SPACE,
|
|
38
|
+
},
|
|
39
|
+
paddingTop: {
|
|
40
|
+
type: 'union',
|
|
41
|
+
className: 'pt',
|
|
42
|
+
values: SPACE,
|
|
43
|
+
},
|
|
44
|
+
paddingRight: {
|
|
45
|
+
type: 'union',
|
|
46
|
+
className: 'pr',
|
|
47
|
+
values: SPACE,
|
|
48
|
+
},
|
|
49
|
+
paddingBottom: {
|
|
50
|
+
type: 'union',
|
|
51
|
+
className: 'pb',
|
|
52
|
+
values: SPACE,
|
|
53
|
+
},
|
|
54
|
+
paddingLeft: {
|
|
55
|
+
type: 'union',
|
|
56
|
+
className: 'pl',
|
|
57
|
+
values: SPACE,
|
|
58
|
+
},
|
|
59
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {PLACEMENT, type Placement} from '../types/Placement'
|
|
2
|
+
import {type PropDef} from '../types/PropDef'
|
|
3
|
+
|
|
4
|
+
/** @public */
|
|
5
|
+
export type PlacementProps = {
|
|
6
|
+
/** Placement relative to anchor */
|
|
7
|
+
placement?: Placement
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const placementProps: Record<string, PropDef> = {
|
|
11
|
+
placement: {
|
|
12
|
+
type: 'union',
|
|
13
|
+
className: 'placement',
|
|
14
|
+
values: PLACEMENT,
|
|
15
|
+
},
|
|
16
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import {POSITION, type Position} from '../types/Position'
|
|
2
|
+
import {type PropDef} from '../types/PropDef'
|
|
3
|
+
import {type Responsive} from '../types/Responsive'
|
|
4
|
+
import {SPACE_AUTO, type SpaceAuto} from '../types/Space'
|
|
5
|
+
|
|
6
|
+
export type PositionProps = {
|
|
7
|
+
/** CSS **position** property */
|
|
8
|
+
position?: Responsive<Position>
|
|
9
|
+
/** CSS **inset** property */
|
|
10
|
+
inset?: Responsive<SpaceAuto>
|
|
11
|
+
/** CSS **top** property */
|
|
12
|
+
top?: Responsive<SpaceAuto>
|
|
13
|
+
/** CSS **right** property */
|
|
14
|
+
right?: Responsive<SpaceAuto>
|
|
15
|
+
/** CSS **bottom** property */
|
|
16
|
+
bottom?: Responsive<SpaceAuto>
|
|
17
|
+
/** CSS **left** property */
|
|
18
|
+
left?: Responsive<SpaceAuto>
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const positionProps: Record<string, PropDef> = {
|
|
22
|
+
position: {
|
|
23
|
+
type: 'union',
|
|
24
|
+
className: 'position',
|
|
25
|
+
values: POSITION,
|
|
26
|
+
},
|
|
27
|
+
inset: {
|
|
28
|
+
type: 'union',
|
|
29
|
+
className: 'inset',
|
|
30
|
+
values: SPACE_AUTO,
|
|
31
|
+
},
|
|
32
|
+
top: {
|
|
33
|
+
type: 'union',
|
|
34
|
+
className: 'top',
|
|
35
|
+
values: SPACE_AUTO,
|
|
36
|
+
},
|
|
37
|
+
right: {
|
|
38
|
+
type: 'union',
|
|
39
|
+
className: 'right',
|
|
40
|
+
values: SPACE_AUTO,
|
|
41
|
+
},
|
|
42
|
+
bottom: {
|
|
43
|
+
type: 'union',
|
|
44
|
+
className: 'bottom',
|
|
45
|
+
values: SPACE_AUTO,
|
|
46
|
+
},
|
|
47
|
+
left: {
|
|
48
|
+
type: 'union',
|
|
49
|
+
className: 'left',
|
|
50
|
+
values: SPACE_AUTO,
|
|
51
|
+
},
|
|
52
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {type PropDef} from '../types/PropDef'
|
|
2
|
+
import {SHADOW, type Shadow} from '../types/Shadow'
|
|
3
|
+
|
|
4
|
+
export type ShadowProps = {
|
|
5
|
+
/** CSS **box-shadow** property */
|
|
6
|
+
shadow?: Shadow
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const shadowProps: Record<string, PropDef> = {
|
|
10
|
+
shadow: {
|
|
11
|
+
type: 'union',
|
|
12
|
+
className: 'shadow',
|
|
13
|
+
values: SHADOW,
|
|
14
|
+
},
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {type PropDef} from '../types/PropDef'
|
|
2
|
+
import {TONE, type Tone} from '../types/Tone'
|
|
3
|
+
|
|
4
|
+
export type ToneProps = {
|
|
5
|
+
/** CSS **background-color** property */
|
|
6
|
+
tone?: Tone
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const toneProps: Record<string, PropDef> = {
|
|
10
|
+
tone: {
|
|
11
|
+
type: 'union',
|
|
12
|
+
className: 'tone',
|
|
13
|
+
values: TONE,
|
|
14
|
+
},
|
|
15
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import {FONT_WEIGHT, type FontWeight} from '../types/FontWeight'
|
|
2
|
+
import {type PropDef} from '../types/PropDef'
|
|
3
|
+
import type {Responsive} from '../types/Responsive'
|
|
4
|
+
import {TEXT_ALIGN, type TextAlign} from '../types/TextAlign'
|
|
5
|
+
import {type MarginProps, marginProps} from './margin'
|
|
6
|
+
import {type ToneProps, toneProps} from './tone'
|
|
7
|
+
|
|
8
|
+
/** @public */
|
|
9
|
+
export interface TypographyProps extends MarginProps, ToneProps {
|
|
10
|
+
/** CSS **text-align** property */
|
|
11
|
+
align?: Responsive<TextAlign>
|
|
12
|
+
/** CSS **color** property */
|
|
13
|
+
muted?: boolean
|
|
14
|
+
/** CSS **text-box-trim** property */
|
|
15
|
+
trim?: boolean
|
|
16
|
+
/** Number of lines to truncate */
|
|
17
|
+
truncate?: Responsive<number>
|
|
18
|
+
/** CSS **font-weight** property */
|
|
19
|
+
weight?: FontWeight
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const typographyProps: Record<string, PropDef> = {
|
|
23
|
+
align: {
|
|
24
|
+
type: 'union',
|
|
25
|
+
className: 'text',
|
|
26
|
+
values: TEXT_ALIGN,
|
|
27
|
+
},
|
|
28
|
+
muted: {
|
|
29
|
+
type: 'boolean',
|
|
30
|
+
className: 'text-muted',
|
|
31
|
+
inverseClassName: 'text-default',
|
|
32
|
+
},
|
|
33
|
+
trim: {
|
|
34
|
+
type: 'boolean',
|
|
35
|
+
className: 'text-trim',
|
|
36
|
+
inverseClassName: 'text-trim-none',
|
|
37
|
+
},
|
|
38
|
+
truncate: {
|
|
39
|
+
type: 'conditional',
|
|
40
|
+
resolve: (value) => {
|
|
41
|
+
if (value === 1) {
|
|
42
|
+
return {
|
|
43
|
+
type: 'number',
|
|
44
|
+
className: 'text-overflow',
|
|
45
|
+
}
|
|
46
|
+
} else {
|
|
47
|
+
return {
|
|
48
|
+
type: 'number',
|
|
49
|
+
className: 'line-clamp',
|
|
50
|
+
variable: '--line-clamp',
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
weight: {
|
|
56
|
+
type: 'union',
|
|
57
|
+
className: 'weight',
|
|
58
|
+
values: FONT_WEIGHT,
|
|
59
|
+
},
|
|
60
|
+
...marginProps,
|
|
61
|
+
...toneProps,
|
|
62
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import {type PropDef} from '../types/PropDef'
|
|
2
|
+
import {type Responsive} from '../types/Responsive'
|
|
3
|
+
|
|
4
|
+
export type WidthProps = {
|
|
5
|
+
/** CSS **width** property */
|
|
6
|
+
width?: Responsive<string>
|
|
7
|
+
/** CSS **min-width** property */
|
|
8
|
+
minWidth?: Responsive<string>
|
|
9
|
+
/** CSS **max-width** property */
|
|
10
|
+
maxWidth?: Responsive<string>
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const widthProps: Record<string, PropDef> = {
|
|
14
|
+
width: {
|
|
15
|
+
type: 'string',
|
|
16
|
+
className: 'width',
|
|
17
|
+
variable: '--width',
|
|
18
|
+
},
|
|
19
|
+
minWidth: {
|
|
20
|
+
type: 'string',
|
|
21
|
+
className: 'min-width',
|
|
22
|
+
variable: '--min-width',
|
|
23
|
+
},
|
|
24
|
+
maxWidth: {
|
|
25
|
+
type: 'string',
|
|
26
|
+
className: 'max-width',
|
|
27
|
+
variable: '--max-width',
|
|
28
|
+
},
|
|
29
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type {PropDef} from '../types/PropDef'
|
|
2
|
+
import type {Responsive} from '../types/Responsive'
|
|
3
|
+
|
|
4
|
+
export type ZIndexProps = {
|
|
5
|
+
/** CSS z-index property */
|
|
6
|
+
zIndex?: Responsive<number>
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const zIndexProps: Record<string, PropDef> = {
|
|
10
|
+
zIndex: {
|
|
11
|
+
type: 'number',
|
|
12
|
+
className: 'z-index',
|
|
13
|
+
variable: '--z-index',
|
|
14
|
+
},
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import {existsSync} from 'node:fs'
|
|
2
|
+
import {createRequire} from 'node:module'
|
|
3
|
+
import {dirname, join} from 'node:path'
|
|
4
|
+
|
|
5
|
+
import {describe, expect, it} from 'vitest'
|
|
6
|
+
|
|
7
|
+
const require = createRequire(import.meta.url)
|
|
8
|
+
|
|
9
|
+
describe('@sanity/ui/styles.css', () => {
|
|
10
|
+
it('resolves to a Node-safe shim under the node condition', () => {
|
|
11
|
+
const path = require.resolve('@sanity/ui/styles.css')
|
|
12
|
+
expect(path).toMatch(/styles\.css\.node\.js$/)
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
it('imports without throwing in Node ESM', async () => {
|
|
16
|
+
const mod = await import('@sanity/ui/styles.css')
|
|
17
|
+
expect(mod.default).toBe('')
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
it('ships the real stylesheet for browser/style resolution', () => {
|
|
21
|
+
const pkgRoot = dirname(require.resolve('@sanity/ui/package.json'))
|
|
22
|
+
expect(existsSync(join(pkgRoot, 'dist/styles.css'))).toBe(true)
|
|
23
|
+
})
|
|
24
|
+
})
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export const BUTTON_DENSITY = ['regular', 'loose'] as const
|
|
2
|
+
export type ButtonDensity = (typeof BUTTON_DENSITY)[number]
|
|
3
|
+
|
|
4
|
+
export const BUTTON_LEVEL = ['primary', 'secondary', 'tertiary'] as const
|
|
5
|
+
export type ButtonLevel = (typeof BUTTON_LEVEL)[number]
|
|
6
|
+
|
|
7
|
+
export const BUTTON_TONE = ['neutral', 'critical'] as const
|
|
8
|
+
export type ButtonTone = (typeof BUTTON_TONE)[number]
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export const DISPLAY_BLOCK = ['block', 'inline-block', 'none'] as const
|
|
2
|
+
/** @public */
|
|
3
|
+
export type DisplayBlock = (typeof DISPLAY_BLOCK)[number]
|
|
4
|
+
|
|
5
|
+
export const DISPLAY_FLEX = ['flex', 'inline-flex', 'none'] as const
|
|
6
|
+
/** @public */
|
|
7
|
+
export type DisplayFlex = (typeof DISPLAY_FLEX)[number]
|
|
8
|
+
|
|
9
|
+
export const DISPLAY_GRID = ['grid', 'inline-grid', 'none'] as const
|
|
10
|
+
/** @public */
|
|
11
|
+
export type DisplayGrid = (typeof DISPLAY_GRID)[number]
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export const ALIGN_ITEMS = ['baseline', 'center', 'flex-end', 'flex-start', 'stretch'] as const
|
|
2
|
+
/** @public */
|
|
3
|
+
export type AlignItems = (typeof ALIGN_ITEMS)[number]
|
|
4
|
+
|
|
5
|
+
export const JUSTIFY_CONTENT = [
|
|
6
|
+
'flex-start',
|
|
7
|
+
'flex-end',
|
|
8
|
+
'center',
|
|
9
|
+
'space-between',
|
|
10
|
+
'space-around',
|
|
11
|
+
'space-evenly',
|
|
12
|
+
] as const
|
|
13
|
+
/** @public */
|
|
14
|
+
export type JustifyContent = (typeof JUSTIFY_CONTENT)[number]
|
|
15
|
+
|
|
16
|
+
export const FLEX_DIRECTION = ['row', 'row-reverse', 'column', 'column-reverse'] as const
|
|
17
|
+
/** @public */
|
|
18
|
+
export type FlexDirection = (typeof FLEX_DIRECTION)[number]
|
|
19
|
+
|
|
20
|
+
export const FLEX_WRAP = ['wrap', 'wrap-reverse', 'nowrap'] as const
|
|
21
|
+
/** @public */
|
|
22
|
+
export type FlexWrap = (typeof FLEX_WRAP)[number]
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export const HEADING_TAG = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'] as const
|
|
2
|
+
export type HeadingTag = (typeof HEADING_TAG)[number]
|
|
3
|
+
|
|
4
|
+
export const HEADING_SIZE = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] as const
|
|
5
|
+
/** @public */
|
|
6
|
+
export type HeadingSize = (typeof HEADING_SIZE)[number]
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const PLACEMENT = [
|
|
2
|
+
'top',
|
|
3
|
+
'top-start',
|
|
4
|
+
'top-end',
|
|
5
|
+
'right',
|
|
6
|
+
'right-start',
|
|
7
|
+
'right-end',
|
|
8
|
+
'bottom',
|
|
9
|
+
'bottom-start',
|
|
10
|
+
'bottom-end',
|
|
11
|
+
'left',
|
|
12
|
+
'left-start',
|
|
13
|
+
'left-end',
|
|
14
|
+
] as const
|
|
15
|
+
/** @public */
|
|
16
|
+
export type Placement = (typeof PLACEMENT)[number]
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prop is a boolean. If used for styling, provide a className
|
|
3
|
+
* to apply CSS and an inverseClassName to reset it.
|
|
4
|
+
*/
|
|
5
|
+
type BooleanPropDef = {
|
|
6
|
+
type: 'boolean'
|
|
7
|
+
className?: string
|
|
8
|
+
inverseClassName?: string
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Prop is a number. If used for styling, provide a className
|
|
13
|
+
* that references the variable for dynamic values.
|
|
14
|
+
*/
|
|
15
|
+
type NumberPropDef = {
|
|
16
|
+
type: 'number'
|
|
17
|
+
className?: string
|
|
18
|
+
variable?: string
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Prop is a string. If used for styling, provide a className
|
|
23
|
+
* that references the variable for dynamic values.
|
|
24
|
+
*/
|
|
25
|
+
type StringPropDef = {
|
|
26
|
+
type: 'string'
|
|
27
|
+
className?: string
|
|
28
|
+
variable?: string
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Prop is a union of values. Values are always required. If
|
|
33
|
+
* used for styling, provide a className.
|
|
34
|
+
*/
|
|
35
|
+
type UnionPropDef<T> = {
|
|
36
|
+
type: 'union'
|
|
37
|
+
className?: string
|
|
38
|
+
values: readonly T[]
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Prop is a composite of other props. Requires a union of values and
|
|
43
|
+
* a composition object which defines the props and their mappings.
|
|
44
|
+
* The values should map to the composition object's mapping keys.
|
|
45
|
+
*/
|
|
46
|
+
type CompositePropDef<T> = {
|
|
47
|
+
type: 'composite'
|
|
48
|
+
values: readonly T[]
|
|
49
|
+
composition: Record<
|
|
50
|
+
string,
|
|
51
|
+
{
|
|
52
|
+
propDef: PropDef
|
|
53
|
+
mapping: Record<T & PropertyKey, unknown>
|
|
54
|
+
}
|
|
55
|
+
>
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Prop is a composite of other props. Requires a resolve callback with
|
|
60
|
+
* a value param that returns another prop def.
|
|
61
|
+
*/
|
|
62
|
+
type ConditionalPropDef<T> = {
|
|
63
|
+
type: 'conditional'
|
|
64
|
+
resolve: (value: T) => PropDef<T>
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export type PropDef<T = unknown> =
|
|
68
|
+
| BooleanPropDef
|
|
69
|
+
| NumberPropDef
|
|
70
|
+
| StringPropDef
|
|
71
|
+
| UnionPropDef<T>
|
|
72
|
+
| CompositePropDef<T>
|
|
73
|
+
| ConditionalPropDef<T>
|