@sanity/ui 5.0.0-alpha.1 → 5.0.0-alpha.11
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 +1 -1
- package/dist/LazyRefractor-CQ22IeXB.js +19 -0
- package/dist/LazyRefractor-CQ22IeXB.js.map +1 -0
- package/dist/cli/install.js +2 -1
- package/dist/index.d.ts +662 -796
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2081 -1758
- 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 -1
- package/package.json +16 -9
- package/src/cli/install.ts +2 -1
- 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.css +5 -0
- package/src/components/box/box.props.ts +7 -2
- package/src/components/button/button.props.ts +27 -9
- package/src/components/card/card.props.ts +6 -2
- package/src/components/checkbox/Checkbox.tsx +4 -3
- package/src/components/checkbox/checkbox.props.ts +11 -3
- package/src/components/code/code.props.ts +10 -3
- package/src/components/container/Container.tsx +5 -1
- package/src/components/container/container.css +4 -0
- package/src/components/container/container.props.ts +6 -2
- 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/eyebrow/Eyebrow.tsx +1 -1
- package/src/components/eyebrow/eyebrow.props.ts +6 -2
- package/src/components/flex/flex.css +5 -0
- package/src/components/flex/flex.props.ts +6 -2
- package/src/components/grid/grid.css +5 -0
- package/src/components/grid/grid.props.ts +6 -2
- package/src/components/h-stack/HStack.tsx +8 -14
- package/src/components/h-stack/hStack.props.ts +5 -13
- package/src/components/heading/Heading.tsx +1 -1
- package/src/components/heading/heading.props.ts +8 -2
- package/src/components/icon/icon.props.ts +6 -2
- package/src/components/icon-button/iconButton.props.ts +7 -2
- package/src/components/index.css +4 -0
- package/src/components/indicator/indicator.props.ts +6 -2
- package/src/components/indicator-stack/indicatorStack.props.ts +3 -1
- package/src/components/inline/inline.props.ts +6 -2
- package/src/components/label/label.props.ts +7 -1
- package/src/components/link/link.props.ts +4 -4
- package/src/components/list/list.props.ts +27 -9
- 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.props.ts +3 -1
- package/src/components/radio/Radio.tsx +1 -1
- package/src/components/radio/radio.props.ts +7 -2
- package/src/components/select/Select.tsx +47 -0
- package/src/components/select/select.css +67 -0
- package/src/components/select/select.props.ts +25 -0
- package/src/components/skip-to-content/skipToContent.props.ts +9 -3
- package/src/components/spinner/Spinner.tsx +1 -1
- package/src/components/spinner/spinner.props.ts +3 -0
- package/src/components/switch/Switch.tsx +1 -1
- package/src/components/switch/switch.props.ts +7 -2
- package/src/components/text/Text.tsx +1 -1
- package/src/components/text/text.props.ts +6 -2
- package/src/components/tooltip/Tooltip.tsx +59 -55
- package/src/components/tooltip/tooltip.css +19 -40
- package/src/components/tooltip/tooltip.props.ts +24 -8
- package/src/components/tooltip-group/TooltipGroup.tsx +2 -5
- package/src/components/tooltip-group/tooltipGroup.props.ts +3 -1
- package/src/components/v-stack/VStack.tsx +8 -14
- package/src/components/v-stack/vStack.props.ts +5 -13
- package/src/components/visually-hidden/visuallyHidden.props.ts +6 -2
- package/src/css/classes/generic/display.css +8 -8
- package/src/css/classes/generic/placement.css +31 -0
- package/src/css/classes/local/animation.css +4 -0
- package/src/css/classes/local/index.css +2 -0
- package/src/css/classes/local/top-anchor.css +4 -0
- package/src/css/classes/system/shadow.css +6 -6
- package/src/css/global/reset.css +32 -19
- package/src/css/tokens/semantic.css +4 -0
- package/src/css/tokens/surface.css +2 -0
- package/src/hooks/useIsClient.ts +10 -0
- package/src/index.ts +8 -0
- package/src/polyfills.ts +17 -0
- package/src/props/formElement.ts +34 -0
- package/src/types/FormElement.ts +2 -0
- package/src/utils/getProps.ts +1 -1
- package/src/utils/mergeTriggerProps.ts +66 -0
- package/src/utils/renderPortal.tsx +14 -0
- package/src/version.ts +2 -2
- package/dist/_chunks-es/LazyRefractor.js +0 -20
- package/dist/_chunks-es/LazyRefractor.js.map +0 -1
package/src/index.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
1
3
|
export * from './components/box/Box'
|
|
2
4
|
export * from './components/button/Button'
|
|
3
5
|
export * from './components/card/Card'
|
|
4
6
|
export * from './components/checkbox/Checkbox'
|
|
5
7
|
export * from './components/code/Code'
|
|
6
8
|
export * from './components/container/Container'
|
|
9
|
+
export * from './components/dialog/Dialog'
|
|
7
10
|
export * from './components/divider/Divider'
|
|
8
11
|
export * from './components/eyebrow/Eyebrow'
|
|
9
12
|
export * from './components/flex/Flex'
|
|
@@ -18,8 +21,10 @@ export * from './components/inline/Inline'
|
|
|
18
21
|
export * from './components/label/Label'
|
|
19
22
|
export * from './components/link/Link'
|
|
20
23
|
export * from './components/list/List'
|
|
24
|
+
export * from './components/popover/Popover'
|
|
21
25
|
export * from './components/press-area/PressArea'
|
|
22
26
|
export * from './components/radio/Radio'
|
|
27
|
+
export * from './components/select/Select'
|
|
23
28
|
export * from './components/skip-to-content/SkipToContent'
|
|
24
29
|
export * from './components/spinner/Spinner'
|
|
25
30
|
export * from './components/switch/Switch'
|
|
@@ -29,6 +34,8 @@ export * from './components/tooltip-group/TooltipGroup'
|
|
|
29
34
|
export * from './components/v-stack/VStack'
|
|
30
35
|
export * from './components/visually-hidden/VisuallyHidden'
|
|
31
36
|
|
|
37
|
+
export * from './hooks/useIsClient'
|
|
38
|
+
|
|
32
39
|
export type {FlexParentProps} from './props/flexParent'
|
|
33
40
|
export type {GapProps} from './props/gap'
|
|
34
41
|
export type {GridParentProps} from './props/gridParent'
|
|
@@ -58,3 +65,4 @@ export type {TextSize} from './types/Text'
|
|
|
58
65
|
export type {TextAlign} from './types/TextAlign'
|
|
59
66
|
export type {FontWeight} from './types/FontWeight'
|
|
60
67
|
export type {Tone} from './types/Tone'
|
|
68
|
+
export * from './components/badge/Badge'
|
package/src/polyfills.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
apply as applyClosedByPolyfill,
|
|
5
|
+
isSupported as isClosedBySupported,
|
|
6
|
+
} from 'dialog-closedby-polyfill'
|
|
7
|
+
|
|
8
|
+
if (
|
|
9
|
+
typeof HTMLButtonElement !== 'undefined' &&
|
|
10
|
+
!('interestForElement' in HTMLButtonElement.prototype)
|
|
11
|
+
) {
|
|
12
|
+
void import('interestfor')
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if (typeof HTMLDialogElement !== 'undefined' && !isClosedBySupported()) {
|
|
16
|
+
applyClosedByPolyfill()
|
|
17
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import {FORM_ELEMENT_DENSITY, type FormElementDensity} from '../types/FormElement'
|
|
2
|
+
import type {PropDef} from '../types/PropDef'
|
|
3
|
+
import {paddingProps} from './padding'
|
|
4
|
+
|
|
5
|
+
/** @public */
|
|
6
|
+
export type FormElementDensityProps = {
|
|
7
|
+
/**
|
|
8
|
+
* Sets padding, gap, and other spacing values on the form element.
|
|
9
|
+
*/
|
|
10
|
+
density?: FormElementDensity
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const formElementDensityProps: Record<string, PropDef> = {
|
|
14
|
+
density: {
|
|
15
|
+
type: 'composite',
|
|
16
|
+
values: FORM_ELEMENT_DENSITY,
|
|
17
|
+
composition: {
|
|
18
|
+
paddingX: {
|
|
19
|
+
propDef: paddingProps['paddingX'] as PropDef,
|
|
20
|
+
mapping: {
|
|
21
|
+
regular: 2,
|
|
22
|
+
loose: 3,
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
paddingY: {
|
|
26
|
+
propDef: paddingProps['paddingY'] as PropDef,
|
|
27
|
+
mapping: {
|
|
28
|
+
regular: 1,
|
|
29
|
+
loose: 2,
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
}
|
package/src/utils/getProps.ts
CHANGED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
function isReactEventHandler(key: string, value: unknown): value is (e: never) => void {
|
|
2
|
+
return /^on[A-Z]/.test(key) && typeof value === 'function'
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
function chainEventHandlers<E>(
|
|
6
|
+
...handlers: (((e: E) => void) | undefined)[]
|
|
7
|
+
): ((e: E) => void) | undefined {
|
|
8
|
+
const defined = handlers.filter(Boolean) as ((e: E) => void)[]
|
|
9
|
+
|
|
10
|
+
if (defined.length === 0) {
|
|
11
|
+
return undefined
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if (defined.length === 1) {
|
|
15
|
+
return defined[0]
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return (e: E) => {
|
|
19
|
+
for (const handler of defined) {
|
|
20
|
+
handler(e)
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function mergeTriggerProps(
|
|
26
|
+
childProps: Record<string, unknown>,
|
|
27
|
+
forwardedProps?: Record<string, unknown>,
|
|
28
|
+
ownProps?: Record<string, unknown>,
|
|
29
|
+
) {
|
|
30
|
+
const result: Record<string, unknown> = {}
|
|
31
|
+
|
|
32
|
+
for (const source of [forwardedProps, ownProps]) {
|
|
33
|
+
if (!source) {
|
|
34
|
+
continue
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
for (const [key, value] of Object.entries(source)) {
|
|
38
|
+
if (key === 'style') {
|
|
39
|
+
continue
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (isReactEventHandler(key, value)) {
|
|
43
|
+
result[key] = chainEventHandlers(result[key] as (e: never) => void, value)
|
|
44
|
+
continue
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (value !== undefined) {
|
|
48
|
+
result[key] = value
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
result['style'] = {
|
|
54
|
+
...(childProps['style'] as object),
|
|
55
|
+
...(forwardedProps?.['style'] as object),
|
|
56
|
+
...(ownProps?.['style'] as object),
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
for (const [key, value] of Object.entries(childProps)) {
|
|
60
|
+
if (isReactEventHandler(key, value)) {
|
|
61
|
+
result[key] = chainEventHandlers(result[key] as (e: never) => void, value)
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return result
|
|
66
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {type ReactNode} from 'react'
|
|
2
|
+
import {createPortal} from 'react-dom'
|
|
3
|
+
|
|
4
|
+
export function renderPortal(node: ReactNode, mounted: boolean, portal?: boolean) {
|
|
5
|
+
if (!portal) {
|
|
6
|
+
return node
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
if (!mounted) {
|
|
10
|
+
return null
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return createPortal(node, document.body)
|
|
14
|
+
}
|
package/src/version.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// This file is generated by scripts/write-version.js. Do not edit.
|
|
2
|
-
export const VERSION = '
|
|
3
|
-
export const HASH = '
|
|
2
|
+
export const VERSION = '500alpha11'
|
|
3
|
+
export const HASH = '8b95a0'
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx } from "react/jsx-runtime";
|
|
3
|
-
import { c } from "react/compiler-runtime";
|
|
4
|
-
import { hasLanguage, Refractor } from "react-refractor";
|
|
5
|
-
function LazyRefractor(t0) {
|
|
6
|
-
const $ = c(5), {
|
|
7
|
-
language,
|
|
8
|
-
value
|
|
9
|
-
} = t0;
|
|
10
|
-
if (!hasLanguage(language)) {
|
|
11
|
-
let t12;
|
|
12
|
-
return $[0] !== value ? (t12 = /* @__PURE__ */ jsx("code", { children: value }), $[0] = value, $[1] = t12) : t12 = $[1], t12;
|
|
13
|
-
}
|
|
14
|
-
let t1;
|
|
15
|
-
return $[2] !== language || $[3] !== value ? (t1 = /* @__PURE__ */ jsx(Refractor, { inline: !0, language, value }), $[2] = language, $[3] = value, $[4] = t1) : t1 = $[4], t1;
|
|
16
|
-
}
|
|
17
|
-
export {
|
|
18
|
-
LazyRefractor as default
|
|
19
|
-
};
|
|
20
|
-
//# sourceMappingURL=LazyRefractor.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LazyRefractor.js","sources":["../../src/components/code/LazyRefractor.tsx"],"sourcesContent":["import {hasLanguage, Refractor, type RefractorProps} from 'react-refractor'\n\nexport default function LazyRefractor({language, value}: RefractorProps) {\n if (!hasLanguage(language)) {\n return <code>{value}</code>\n }\n\n return <Refractor inline language={language} value={value} />\n}\n"],"names":["LazyRefractor","t0","$","_c","language","value","hasLanguage","t1"],"mappings":";;;;AAEA,SAAeA,cAAAC,IAAA;AAAA,QAAAC,IAAAC,EAAA,CAAA,GAAuB;AAAA,IAAAC;AAAAA,IAAAC;AAAAA,EAAAA,IAAAJ;AACpC,MAAI,CAACK,YAAYF,QAAQ,GAAC;AAAA,QAAAG;AAAA,WAAAL,SAAAG,SACjBE,MAAA,oBAAA,QAAA,EAAOF,iBAAM,GAAOH,OAAAG,OAAAH,OAAAK,OAAAA,MAAAL,EAAA,CAAA,GAApBK;AAAAA,EAAoB;AAC5B,MAAAA;AAAA,SAAAL,EAAA,CAAA,MAAAE,YAAAF,SAAAG,SAEME,yBAAC,WAAA,EAAU,YAAiBH,UAAiBC,MAAAA,CAAK,GAAIH,OAAAE,UAAAF,OAAAG,OAAAH,OAAAK,MAAAA,KAAAL,EAAA,CAAA,GAAtDK;AAAsD;"}
|