@sanity-labs/ui-poc 0.0.1-alpha.12 → 0.0.1-alpha.14

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.
Files changed (85) hide show
  1. package/dist/index.d.ts +267 -33
  2. package/dist/index.js +669 -159
  3. package/dist/index.js.map +1 -1
  4. package/dist/styles.css +1 -1
  5. package/package.json +2 -2
  6. package/src/components/box/box.css +3 -4
  7. package/src/components/button/Button.tsx +61 -0
  8. package/src/components/button/button.css +80 -0
  9. package/src/components/button/button.props.ts +88 -0
  10. package/src/components/card/Card.tsx +1 -1
  11. package/src/components/card/card.css +2 -5
  12. package/src/components/card/card.props.ts +9 -0
  13. package/src/components/checkbox/Checkbox.tsx +8 -3
  14. package/src/components/checkbox/checkbox.css +76 -12
  15. package/src/components/checkbox/checkbox.props.ts +9 -4
  16. package/src/components/code/Code.tsx +4 -3
  17. package/src/components/code/code.css +5 -1
  18. package/src/components/code/code.props.ts +5 -3
  19. package/src/components/container/container.css +3 -3
  20. package/src/components/flex/flex.css +3 -4
  21. package/src/components/grid/grid.css +3 -4
  22. package/src/components/h-stack/HStack.tsx +29 -0
  23. package/src/components/h-stack/hStack.props.ts +15 -0
  24. package/src/components/heading/heading.css +4 -4
  25. package/src/components/icon/icon.css +4 -4
  26. package/src/components/icon/icon.props.ts +2 -3
  27. package/src/components/index.css +8 -0
  28. package/src/components/indicator/Indicator.tsx +37 -0
  29. package/src/components/indicator/indicator.css +4 -0
  30. package/src/components/indicator/indicator.props.ts +20 -0
  31. package/src/components/indicator-group/IndicatorGroup.tsx +26 -0
  32. package/src/components/indicator-group/indicator-group.css +7 -0
  33. package/src/components/indicator-group/indicatorGroup.props.ts +13 -0
  34. package/src/components/inline/Inline.tsx +35 -0
  35. package/src/components/inline/inline.css +4 -0
  36. package/src/components/inline/inline.props.ts +96 -0
  37. package/src/components/label/Label.tsx +2 -1
  38. package/src/components/label/label.css +2 -2
  39. package/src/components/label/label.props.ts +4 -0
  40. package/src/components/link/Link.tsx +24 -0
  41. package/src/components/link/link.css +12 -0
  42. package/src/components/link/link.props.ts +23 -0
  43. package/src/components/list/List.tsx +106 -0
  44. package/src/components/list/list.css +10 -0
  45. package/src/components/list/list.props.ts +78 -0
  46. package/src/components/radio/Radio.tsx +11 -4
  47. package/src/components/radio/radio.css +81 -10
  48. package/src/components/radio/radio.props.ts +5 -0
  49. package/src/components/skip-to-content/SkipToContent.tsx +30 -0
  50. package/src/components/skip-to-content/skip-to-content.css +9 -0
  51. package/src/components/skip-to-content/skipToContent.props.ts +24 -0
  52. package/src/components/spinner/Spinner.tsx +23 -0
  53. package/src/components/spinner/spinner.css +10 -0
  54. package/src/components/spinner/spinner.props.ts +16 -0
  55. package/src/components/switch/Switch.tsx +7 -16
  56. package/src/components/switch/switch.css +96 -17
  57. package/src/components/switch/switch.props.ts +5 -5
  58. package/src/components/text/text.css +4 -4
  59. package/src/components/v-stack/VStack.tsx +27 -0
  60. package/src/components/v-stack/vStack.props.ts +15 -0
  61. package/src/components/visually-hidden/visually-hidden.css +1 -1
  62. package/src/components/visually-hidden/visuallyHidden.props.ts +6 -0
  63. package/src/css/classes/dynamic/width.css +2 -0
  64. package/src/css/classes/local/border.css +14 -10
  65. package/src/css/classes/local/tone.css +60 -33
  66. package/src/css/classes/system/gap.css +3 -0
  67. package/src/css/classes/system/margin.css +63 -0
  68. package/src/css/global/reset.css +1 -0
  69. package/src/css/tokens/index.css +3 -2
  70. package/src/css/tokens/opacity.css +6 -0
  71. package/src/css/tokens/semantic.css +21 -0
  72. package/src/css/tokens/surface.css +27 -0
  73. package/src/index.ts +10 -0
  74. package/src/props/flexParent.ts +1 -1
  75. package/src/props/gap.ts +7 -7
  76. package/src/props/margin.ts +15 -15
  77. package/src/types/Button.ts +8 -0
  78. package/src/types/Interactive.ts +8 -0
  79. package/src/types/List.ts +2 -0
  80. package/src/types/Space.ts +6 -0
  81. package/src/types/Tone.ts +1 -9
  82. package/src/utils/getProps.test.ts +4 -2
  83. package/src/utils/getProps.ts +7 -1
  84. package/src/css/tokens/border.css +0 -3
  85. package/src/css/tokens/tone.css +0 -30
package/dist/index.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  import type {ComponentProps} from 'react'
2
- import type {ComponentPropsWithRef} from 'react'
3
- import type {ElementType} from 'react'
2
+ import {ComponentPropsWithRef} from 'react'
3
+ import {ElementType} from 'react'
4
4
  import {JSX} from 'react/jsx-runtime'
5
+ import type {default as React_2} from 'react'
5
6
  import type {SVGProps} from 'react'
6
7
 
7
8
  declare const ALIGN_ITEMS: readonly ['baseline', 'center', 'flex-end', 'flex-start', 'stretch']
@@ -37,6 +38,48 @@ declare interface BoxProps<T extends React.ElementType> extends LayoutProps {
37
38
  display?: Responsive<DisplayBlock>
38
39
  }
39
40
 
41
+ /** @public */
42
+ export declare function Button<T extends ElementType = 'button'>({
43
+ density,
44
+ level,
45
+ tone,
46
+ ...props
47
+ }: ButtonProps<T> & Omit<ComponentPropsWithRef<T>, keyof ButtonProps<T>>): JSX.Element
48
+
49
+ declare const BUTTON_DENSITY: readonly ['regular', 'loose']
50
+
51
+ declare const BUTTON_LEVEL: readonly ['primary', 'secondary', 'tertiary']
52
+
53
+ declare const BUTTON_TONE: readonly ['neutral', 'critical']
54
+
55
+ declare type ButtonDensity = (typeof BUTTON_DENSITY)[number]
56
+
57
+ declare type ButtonLevel = (typeof BUTTON_LEVEL)[number]
58
+
59
+ /** @public */
60
+ declare interface ButtonProps<T extends React.ElementType> {
61
+ /** Element to render */
62
+ as?: InteractiveAs<T>
63
+ /** Composite prop for setting padding and gap */
64
+ density?: ButtonDensity
65
+ /** Set CSS **width** property to 100% */
66
+ fullWidth?: Responsive<boolean>
67
+ /** Starting icon */
68
+ iconStart?: React.ElementType | React.ReactNode
69
+ /** Ending icon */
70
+ iconEnd?: React.ElementType | React.ReactNode
71
+ /** Button level */
72
+ level?: ButtonLevel
73
+ /** Loading state */
74
+ loading?: boolean
75
+ /** Button text */
76
+ text?: string
77
+ /** Button tone */
78
+ tone?: ButtonTone
79
+ }
80
+
81
+ declare type ButtonTone = (typeof BUTTON_TONE)[number]
82
+
40
83
  /** @public */
41
84
  export declare function Card<T extends ElementType = 'div'>({
42
85
  density,
@@ -57,27 +100,31 @@ export declare function Checkbox(props: CheckboxProps): JSX.Element
57
100
 
58
101
  /** @beta */
59
102
  declare interface CheckboxProps extends React.ComponentProps<'input'>, MarginProps {
60
- /** Input label */
61
- label: React.ReactNode
103
+ /** Error state */
104
+ error?: boolean
62
105
  /** Indeterminate state */
63
106
  indeterminate?: boolean
107
+ /** Input label */
108
+ label: React.ReactNode
64
109
  }
65
110
 
66
111
  /** @public */
67
- export declare function Code<T extends React.ElementType = 'pre'>({
112
+ export declare function Code<T extends CodeTag = 'pre'>({
68
113
  size,
69
114
  ...props
70
- }: CodeProps & Omit<React.ComponentPropsWithRef<T>, keyof CodeProps>): JSX.Element
115
+ }: CodeProps<T> & Omit<ComponentPropsWithRef<T>, keyof CodeProps<T>>): JSX.Element
71
116
 
72
117
  declare const CODE_SIZE: readonly [0, 1, 2, 3, 4]
73
118
 
74
119
  declare const CODE_TAG: readonly ['pre', 'span']
75
120
 
76
121
  /** @public */
77
- declare interface CodeProps
78
- extends React.ComponentProps<'pre'>, Omit<TypographyProps, 'align' | 'lineClamp' | 'tone'> {
122
+ declare interface CodeProps<T extends CodeTag> extends Omit<
123
+ TypographyProps,
124
+ 'align' | 'lineClamp' | 'tone'
125
+ > {
79
126
  /** Element to render */
80
- as?: CodeTag
127
+ as?: T
81
128
  /** Refractor language for syntax highlighting */
82
129
  language?: string
83
130
  /** CSS **font-size** property */
@@ -177,11 +224,11 @@ declare type FontWeight = (typeof FONT_WEIGHT)[number]
177
224
 
178
225
  declare type GapProps = {
179
226
  /** CSS **gap** property */
180
- gap?: Responsive<Space>
227
+ gap?: Responsive<SpaceInherit>
181
228
  /** CSS **row-gap** property */
182
- rowGap?: Responsive<Space>
229
+ rowGap?: Responsive<SpaceInherit>
183
230
  /** CSS **column-gap** property */
184
- columnGap?: Responsive<Space>
231
+ columnGap?: Responsive<SpaceInherit>
185
232
  }
186
233
 
187
234
  /** @public */
@@ -263,23 +310,83 @@ declare type HeightProps = {
263
310
  maxHeight?: Responsive<string>
264
311
  }
265
312
 
313
+ /** @public */
314
+ export declare function HStack<T extends ElementType = 'div'>(
315
+ props: HStackProps<T> & Omit<ComponentPropsWithRef<T>, keyof HStackProps<T>>,
316
+ ): JSX.Element
317
+
318
+ /** @public */
319
+ declare interface HStackProps<T extends React.ElementType> extends Pick<GapProps, 'gap'> {
320
+ /** Element to render */
321
+ as?: T
322
+ }
323
+
266
324
  /** @public */
267
325
  export declare function Icon({icon: Component, size, ...props}: IconProps): JSX.Element
268
326
 
269
327
  declare const ICON_SIZE: readonly [0, 1, 2, 3, 4]
270
328
 
271
329
  /** @public */
272
- declare interface IconProps extends ComponentProps<'svg'>, MarginProps, ToneProps {
330
+ declare interface IconProps
331
+ extends ComponentProps<'svg'>, Pick<TypographyProps, 'muted'>, MarginProps, ToneProps {
273
332
  /** Icon to render */
274
333
  icon: React.ComponentType<SVGProps<SVGSVGElement>>
275
334
  /** CSS **font-size** property */
276
335
  size?: Responsive<IconSize>
277
- /** CSS **color** property */
278
- muted?: TypographyProps['muted']
279
336
  }
280
337
 
281
338
  declare type IconSize = (typeof ICON_SIZE)[number]
282
339
 
340
+ /** @beta */
341
+ export declare function Indicator<T extends ElementType = 'span'>({
342
+ tone,
343
+ ...props
344
+ }: IndicatorProps<T> & Omit<ComponentPropsWithRef<T>, keyof IndicatorProps<T>>): JSX.Element
345
+
346
+ /** @public */
347
+ export declare function IndicatorGroup<T extends ElementType = 'div'>(
348
+ props: IndicatorGroupProps<T> & Omit<ComponentPropsWithRef<T>, keyof IndicatorGroupProps<T>>,
349
+ ): JSX.Element
350
+
351
+ /** @public */
352
+ declare interface IndicatorGroupProps<T extends React.ElementType> {
353
+ /** Element to render */
354
+ as?: T
355
+ }
356
+
357
+ /** @beta */
358
+ declare interface IndicatorProps<T extends React.ElementType> extends ToneProps {
359
+ /** Element to render */
360
+ as?: T
361
+ /** Label for aria-label attribute */
362
+ label?: string
363
+ }
364
+
365
+ /** @deprecated Use HStack component instead */
366
+ /** @public */
367
+ export declare function Inline<T extends ElementType = 'div'>(
368
+ props: InlineProps<T> & Omit<ComponentPropsWithRef<T>, keyof InlineProps<T>>,
369
+ ): JSX.Element
370
+
371
+ /** @deprecated Use HStack component instead */
372
+ /** @public */
373
+ declare interface InlineProps<T extends React.ElementType> extends PaddingProps {
374
+ /** Element to render */
375
+ as?: T
376
+ /** CSS **gap** property */
377
+ gap?: Responsive<SpaceInherit>
378
+ }
379
+
380
+ declare const INTERACTIVE_TAG: readonly ['button', 'a']
381
+
382
+ declare type InteractiveAs<T extends React.ElementType> = T extends InteractiveTag
383
+ ? T
384
+ : T extends string
385
+ ? never
386
+ : T
387
+
388
+ declare type InteractiveTag = (typeof INTERACTIVE_TAG)[number]
389
+
283
390
  declare const JUSTIFY_CONTENT: readonly [
284
391
  'flex-start',
285
392
  'flex-end',
@@ -298,6 +405,7 @@ export declare function Label(props: LabelProps): JSX.Element
298
405
  declare interface LabelProps extends React.ComponentProps<'label'>, MarginProps {
299
406
  /** Element to render */
300
407
  disabled?: boolean
408
+ error?: boolean
301
409
  }
302
410
 
303
411
  declare interface LayoutProps
@@ -315,21 +423,86 @@ declare interface LayoutProps
315
423
  ZIndexProps,
316
424
  ShadowProps {}
317
425
 
426
+ /** @beta */
427
+ export declare function Link({underlined, ...props}: LinkProps): JSX.Element
428
+
429
+ /** @beta */
430
+ declare interface LinkProps extends React.ComponentProps<'a'> {
431
+ /** If true, sets `target="_blank"` and `rel="noopener noreferrer"` */
432
+ openInNewTab?: boolean
433
+ /**
434
+ * If true, sets `text-decoration: underline`
435
+ *
436
+ * @defaultValue true
437
+ */
438
+ underlined?: boolean
439
+ }
440
+
441
+ /** @beta */
442
+ export declare const List: typeof ListRoot
443
+
444
+ declare const LIST_TAG: readonly ['ol', 'ul']
445
+
446
+ declare function ListItem({density, ...props}: ListItemProps): JSX.Element
447
+
448
+ declare function ListItemImage(props: ComponentProps<'img'>): JSX.Element
449
+
450
+ /** @beta */
451
+ declare interface ListItemProps extends React_2.ComponentProps<'li'> {
452
+ /** Composite prop for setting padding and gap */
453
+ density?: Responsive<Density>
454
+ /** Trailing slot */
455
+ trailing?: React_2.ReactNode
456
+ }
457
+
458
+ declare function ListItemText<T extends ElementType = 'div'>(
459
+ props: ListItemTextProps<T> & Omit<ComponentPropsWithRef<T>, keyof ListItemTextProps<T>>,
460
+ ): JSX.Element
461
+
462
+ /** @beta */
463
+ declare interface ListItemTextProps<T extends React_2.ElementType> {
464
+ /** Element to render */
465
+ as?: T
466
+ /** Title text */
467
+ title?: React_2.ReactNode
468
+ /** Subtitle text */
469
+ subtitle?: React_2.ReactNode
470
+ }
471
+
472
+ /** @beta */
473
+ declare interface ListProps<T extends ListTag> {
474
+ /** Element to render */
475
+ as?: T
476
+ }
477
+
478
+ declare function ListRoot<T extends ListTag = 'ul'>(
479
+ props: ListProps<T> & Omit<ComponentPropsWithRef<T>, keyof ListProps<T>>,
480
+ ): JSX.Element
481
+
482
+ declare namespace ListRoot {
483
+ var displayName: string
484
+ var Item: typeof ListItem
485
+ var ItemText: typeof ListItemText
486
+ var ItemImage: typeof ListItemImage
487
+ }
488
+
489
+ declare type ListTag = (typeof LIST_TAG)[number]
490
+
318
491
  declare type MarginProps = {
319
492
  /** CSS **margin** property */
320
- margin?: Responsive<SpaceAuto>
493
+ margin?: Responsive<SpaceAutoNegative>
321
494
  /** CSS **margin-left** and **margin-right** properties */
322
- marginX?: Responsive<SpaceAuto>
495
+ marginX?: Responsive<SpaceAutoNegative>
323
496
  /** CSS **margin-top** and **margin-bottom** properties */
324
- marginY?: Responsive<SpaceAuto>
497
+ marginY?: Responsive<SpaceAutoNegative>
325
498
  /** CSS **margin-top** property */
326
- marginTop?: Responsive<SpaceAuto>
499
+ marginTop?: Responsive<SpaceAutoNegative>
327
500
  /** CSS **margin-right** property */
328
- marginRight?: Responsive<SpaceAuto>
501
+ marginRight?: Responsive<SpaceAutoNegative>
329
502
  /** CSS **margin-bottom** property */
330
- marginBottom?: Responsive<SpaceAuto>
503
+ marginBottom?: Responsive<SpaceAutoNegative>
331
504
  /** CSS **margin-left** property */
332
- marginLeft?: Responsive<SpaceAuto>
505
+ marginLeft?: Responsive<SpaceAutoNegative>
333
506
  }
334
507
 
335
508
  declare const OVERFLOW: readonly ['visible', 'hidden', 'auto', 'scroll', 'clip']
@@ -386,6 +559,8 @@ export declare function Radio(props: RadioProps): JSX.Element
386
559
 
387
560
  /** @beta */
388
561
  declare interface RadioProps extends React.ComponentProps<'input'>, MarginProps {
562
+ /** Error state */
563
+ error?: boolean
389
564
  /** Input label */
390
565
  label: React.ReactNode
391
566
  }
@@ -421,23 +596,77 @@ declare type ShadowProps = {
421
596
  shadow?: string
422
597
  }
423
598
 
599
+ /** @beta */
600
+ export declare function SkipToContent(props: SkipToContentProps): JSX.Element
601
+
602
+ /** @beta */
603
+ declare interface SkipToContentProps extends React.ComponentProps<'a'> {
604
+ /**
605
+ * Anchor hash. The target element should be focusable or have `tabindex="-1"` applied.
606
+ */
607
+ hash: string
608
+ /** Use href instead */
609
+ href?: never
610
+ /** Visible/announced label */
611
+ label: string
612
+ /** Use label instead */
613
+ children?: never
614
+ }
615
+
424
616
  declare const SPACE: readonly [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
425
617
 
426
618
  declare type Space = (typeof SPACE)[number]
427
619
 
428
620
  declare const SPACE_AUTO: readonly [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 'auto']
429
621
 
622
+ declare const SPACE_AUTO_NEGATIVE: readonly [
623
+ -9,
624
+ -8,
625
+ -7,
626
+ -6,
627
+ -5,
628
+ -4,
629
+ -3,
630
+ -2,
631
+ -1,
632
+ 0,
633
+ 1,
634
+ 2,
635
+ 3,
636
+ 4,
637
+ 5,
638
+ 6,
639
+ 7,
640
+ 8,
641
+ 9,
642
+ 'auto',
643
+ ]
644
+
645
+ declare const SPACE_INHERIT: readonly [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 'inherit']
646
+
430
647
  declare type SpaceAuto = (typeof SPACE_AUTO)[number]
431
648
 
649
+ declare type SpaceAutoNegative = (typeof SPACE_AUTO_NEGATIVE)[number]
650
+
651
+ declare type SpaceInherit = (typeof SPACE_INHERIT)[number]
652
+
653
+ /** @public */
654
+ export declare function Spinner({size, ...props}: SpinnerProps): JSX.Element
655
+
656
+ /** @public */
657
+ declare interface SpinnerProps extends React.ComponentProps<'svg'> {
658
+ size?: Responsive<IconSize>
659
+ }
660
+
432
661
  /** @beta */
433
662
  export declare function Switch(props: SwitchProps): JSX.Element
434
663
 
435
664
  /** @beta */
436
665
  declare interface SwitchProps extends React.ComponentProps<'input'>, MarginProps {
666
+ /** Error state */
667
+ error?: boolean
437
668
  /** Input label */
438
669
  label: React.ReactNode
439
- /** Indeterminate state */
440
- indeterminate?: boolean
441
670
  }
442
671
 
443
672
  /** @public */
@@ -463,15 +692,7 @@ declare interface TextProps<T extends React.ElementType> extends TypographyProps
463
692
 
464
693
  declare type TextSize = (typeof TEXT_SIZE)[number]
465
694
 
466
- declare const TONE: readonly [
467
- 'none',
468
- 'neutral',
469
- 'primary',
470
- 'positive',
471
- 'suggest',
472
- 'caution',
473
- 'critical',
474
- ]
695
+ declare const TONE: readonly ['neutral', 'positive', 'suggest', 'caution', 'critical']
475
696
 
476
697
  declare type Tone = (typeof TONE)[number]
477
698
 
@@ -502,6 +723,19 @@ export declare function VisuallyHidden<T extends ElementType = 'span'>(
502
723
  declare interface VisuallyHiddenProps<T extends React.ElementType> {
503
724
  /** Element to render */
504
725
  as?: T
726
+ /** If true, element is visible on :focus-visible */
727
+ visibleOnFocus?: boolean
728
+ }
729
+
730
+ /** @public */
731
+ export declare function VStack<T extends ElementType = 'div'>(
732
+ props: VStackProps<T> & Omit<ComponentPropsWithRef<T>, keyof VStackProps<T>>,
733
+ ): JSX.Element
734
+
735
+ /** @public */
736
+ declare interface VStackProps<T extends React.ElementType> extends Pick<GapProps, 'gap'> {
737
+ /** Element to render */
738
+ as?: T
505
739
  }
506
740
 
507
741
  declare type WidthProps = {