@wistia/ui 0.0.21 → 0.0.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import * as react from 'react';
3
- import { ReactNode, ComponentPropsWithoutRef, JSX, ComponentPropsWithRef, MouseEvent, ChangeEvent, JSXElementConstructor, ElementType as ElementType$1 } from 'react';
3
+ import { ReactNode, ComponentPropsWithoutRef, JSX, ComponentPropsWithRef, MouseEvent, ChangeEvent, ForwardedRef, Ref, JSXElementConstructor, ElementType as ElementType$1 } from 'react';
4
4
  import { LinkProps as LinkProps$1 } from 'react-router-dom';
5
5
  import * as styled_components from 'styled-components';
6
6
  import { DropdownMenuContentProps, DropdownMenuItemProps, DropdownMenuRadioGroupProps, DropdownMenuRadioItemProps, DropdownMenuCheckboxItemProps } from '@radix-ui/react-dropdown-menu';
@@ -515,6 +515,108 @@ declare const Ellipsis: {
515
515
  displayName: string;
516
516
  };
517
517
 
518
+ type ActionCallback<T> = (data: T, nextData: T) => Promise<T> | T;
519
+ type Action = (data: FormData | null) => Promise<void>;
520
+ type FormActionState<T> = [{
521
+ data: T;
522
+ error: Error | null;
523
+ }, Action, boolean];
524
+ declare const useFormState: <T extends object>(action: ActionCallback<T>, initialData?: Partial<T>) => FormActionState<T>;
525
+
526
+ type ValidationCallback<T> = (data: T) => FormErrors<T>;
527
+ type FormWithLabelledByProps = {
528
+ 'aria-label'?: never;
529
+ /**
530
+ * The id of the element that labels the form. Typically a heading.
531
+ */
532
+ 'aria-labelledby': string;
533
+ };
534
+ type FormWithLabelProps = {
535
+ /**
536
+ * Accessible name of the form. Use this only when a visible label is not possible. If the form has a title or heading, use `aria-labelledby` instead.
537
+ */
538
+ 'aria-label': string;
539
+ 'aria-labelledby'?: never;
540
+ };
541
+ type FormErrors<T> = Partial<{
542
+ [K in keyof T]: string[] | string;
543
+ }>;
544
+ type FormProps<T> = Omit<ComponentPropsWithoutRef<'form'>, 'action' | 'aria-label' | 'aria-labelledby' | 'children'> & {
545
+ /**
546
+ * The action to be performed when the form is submitted. It can be asynchronous.
547
+ */
548
+ action?: Action;
549
+ /**
550
+ * The form elements used in the form
551
+ */
552
+ children: ReactNode;
553
+ /**
554
+ * An object that providesd errors for the form fields. This is created by `useFormState` and passed along to `FormField`s.
555
+ */
556
+ errors?: FormErrors<T>;
557
+ /**
558
+ * If true, fills the entire container
559
+ */
560
+ fullWidth?: boolean;
561
+ /**
562
+ * The function for handling validation.
563
+ */
564
+ validate?: ValidationCallback<T>;
565
+ /**
566
+ * An object that provides valuesfor the form fields. This is typically the `state.data` value from `useFormState` and passed along to `FormField`s.
567
+ */
568
+ values?: T;
569
+ } & (FormWithLabelledByProps | FormWithLabelProps);
570
+ /**
571
+ * x
572
+ */
573
+ declare const FormComponent: {
574
+ <T>({ children, action, values, validate, fullWidth, ...props }: FormProps<T>, forwardedRef?: Ref<HTMLFormElement>): JSX.Element;
575
+ displayName: string;
576
+ };
577
+ declare const Form: <T>(props: FormProps<T> & {
578
+ ref?: ForwardedRef<HTMLUListElement>;
579
+ }) => ReturnType<typeof FormComponent>;
580
+
581
+ type FormErrorSummaryProps = {
582
+ description: string;
583
+ };
584
+ declare const FormErrorSummary: ({ description }: FormErrorSummaryProps) => react_jsx_runtime.JSX.Element | null;
585
+
586
+ type FormFieldProps = ComponentPropsWithoutRef<'div'> & {
587
+ /**
588
+ * This should be a single child that is a valid form field (or can pretend to be one).
589
+ */
590
+ children: JSX.Element;
591
+ /**
592
+ * Valid label text
593
+ */
594
+ label: ReactNode;
595
+ /**
596
+ * If an id isn't supplied, one is generated internally.
597
+ */
598
+ id?: string;
599
+ /**
600
+ * Will show an error message and put the child input into an invalid state
601
+ */
602
+ error?: ReactNode;
603
+ /**
604
+ * The name attribute of the field. It will map to the form data passed into `useFormState`.
605
+ */
606
+ name: string;
607
+ /**
608
+ * A value that overrides the basic value. This should pair with `onChange`.
609
+ */
610
+ value?: string;
611
+ };
612
+ /**
613
+ * Component description goes here
614
+ */
615
+ declare const FormField: {
616
+ ({ children, label, name, error, value, ...props }: FormFieldProps): JSX.Element;
617
+ displayName: string;
618
+ };
619
+
518
620
  type ExtendedProps<Props = Record<string, unknown>, OverrideProps = Record<string, unknown>> = Omit<Props, keyof OverrideProps> & OverrideProps;
519
621
  type ElementType = JSXElementConstructor<any> | keyof JSX.IntrinsicElements;
520
622
  type PropsOf<C extends ElementType> = JSX.LibraryManagedAttributes<C, ComponentPropsWithoutRef<C>>;
@@ -1366,6 +1468,8 @@ declare const RadioMenuItem: {
1366
1468
  };
1367
1469
 
1368
1470
  type CheckboxMenuItemProps = DropdownMenuCheckboxItemProps & MenuItemButtonProps & {
1471
+ /** Callback to fire when the checked status changes */
1472
+ onCheckedChange: (checked: boolean) => void;
1369
1473
  /**
1370
1474
  * an [Icon](?path=/docs/components-icon--docs) to use as the indicator that the radio item is selected
1371
1475
  */
@@ -1388,7 +1492,7 @@ type CheckboxMenuItemProps = DropdownMenuCheckboxItemProps & MenuItemButtonProps
1388
1492
  ref?: never;
1389
1493
  };
1390
1494
  declare const CheckboxMenuItem: {
1391
- ({ onSelect, checked, onCheckedChange, indicator, ...props }: CheckboxMenuItemProps): react_jsx_runtime.JSX.Element;
1495
+ ({ onSelect, checked, onCheckedChange, ...props }: CheckboxMenuItemProps): react_jsx_runtime.JSX.Element;
1392
1496
  displayName: string;
1393
1497
  };
1394
1498
 
@@ -1404,7 +1508,7 @@ type RadioProps = ComponentPropsWithoutRef<'input'> & {
1404
1508
  /**
1405
1509
  * Indicates that there is an error with the input
1406
1510
  */
1407
- hasError?: boolean;
1511
+ 'aria-invalid'?: boolean;
1408
1512
  /**
1409
1513
  * Provides an ID for the input
1410
1514
  */
@@ -1447,7 +1551,7 @@ declare const Radio: react.ForwardRefExoticComponent<Omit<react.DetailedHTMLProp
1447
1551
  /**
1448
1552
  * Indicates that there is an error with the input
1449
1553
  */
1450
- hasError?: boolean;
1554
+ 'aria-invalid'?: boolean;
1451
1555
  /**
1452
1556
  * Provides an ID for the input
1453
1557
  */
@@ -1660,4 +1764,42 @@ declare const WistiaLogo: {
1660
1764
  displayName: string;
1661
1765
  };
1662
1766
 
1663
- export { Avatar, type AvatarInstanceType, type AvatarProps, Badge, type BadgeProps, Box, type BoxProps, Button, ButtonGroup, type ButtonProps, Checkbox, CheckboxMenuItem, type ColorSchemeTypes, ColorSchemeWrapper, type ColorSchemeWrapperProps, Divider, Ellipsis, Heading, type HeadingProps, Icon, IconButton, type IconButtonProps, type IconNameType, Label, type LabelProps, Link, type LinkProps, Menu, MenuItem, MenuItemDescription, MenuItemLabel, MenuLabel, MenuRadioGroup, Radio, RadioMenuItem, type RadioProps, ScreenReaderOnly, Stack, SubMenu, Tag, type TagProps, Text, type TextProps, Tooltip, type TooltipProps, UIProvider, WistiaLogo, colorSchemeOptions, copyToClipboard, ellipsisFlexParentStyle, ellipsisStyle, iconSizeMap, mq, useActiveMq, useAriaLive, useMq, useWindowSize };
1767
+ type FormGroupProps = Omit<ComponentPropsWithoutRef<'fieldset'>, 'onChange'> & {
1768
+ children: ReactNode;
1769
+ label?: ReactNode;
1770
+ };
1771
+ /**
1772
+ * For grouping like form elements together.
1773
+ */
1774
+ declare const FormGroup: {
1775
+ ({ children, label, ...props }: FormGroupProps): JSX.Element;
1776
+ displayName: string;
1777
+ };
1778
+
1779
+ type RadioGroupProps = FormGroupProps & {
1780
+ onChange?: ((event: ChangeEvent<HTMLInputElement>) => void) | undefined;
1781
+ value?: string | undefined;
1782
+ name?: string | undefined;
1783
+ };
1784
+ /**
1785
+ * For grouping like form elements togtether. Can serve as a checkbox
1786
+ */
1787
+ declare const RadioGroup: {
1788
+ ({ children, name, onChange, value, ...props }: RadioGroupProps): JSX.Element;
1789
+ displayName: string;
1790
+ };
1791
+
1792
+ type CheckboxGroupProps = FormGroupProps & {
1793
+ onChange?: ((event: ChangeEvent<HTMLInputElement>) => void) | undefined;
1794
+ value?: string | undefined;
1795
+ name?: string | undefined;
1796
+ };
1797
+ /**
1798
+ * For grouping like form elements togtether. Can serve as a checkbox
1799
+ */
1800
+ declare const CheckboxGroup: {
1801
+ ({ children, name, onChange, value, ...props }: CheckboxGroupProps): JSX.Element;
1802
+ displayName: string;
1803
+ };
1804
+
1805
+ export { Avatar, type AvatarInstanceType, type AvatarProps, Badge, type BadgeProps, Box, type BoxProps, Button, ButtonGroup, type ButtonProps, Checkbox, CheckboxGroup, CheckboxMenuItem, type ColorSchemeTypes, ColorSchemeWrapper, type ColorSchemeWrapperProps, Divider, Ellipsis, Form, FormErrorSummary, FormField, type FormFieldProps, FormGroup, type FormGroupProps, type FormProps, Heading, type HeadingProps, Icon, IconButton, type IconButtonProps, type IconNameType, Label, type LabelProps, Link, type LinkProps, Menu, MenuItem, MenuItemDescription, MenuItemLabel, MenuLabel, MenuRadioGroup, Radio, RadioGroup, RadioMenuItem, type RadioProps, ScreenReaderOnly, Stack, SubMenu, Tag, type TagProps, Text, type TextProps, Tooltip, type TooltipProps, UIProvider, WistiaLogo, colorSchemeOptions, copyToClipboard, ellipsisFlexParentStyle, ellipsisStyle, iconSizeMap, mq, useActiveMq, useAriaLive, useFormState, useMq, useWindowSize };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import * as react from 'react';
3
- import { ReactNode, ComponentPropsWithoutRef, JSX, ComponentPropsWithRef, MouseEvent, ChangeEvent, JSXElementConstructor, ElementType as ElementType$1 } from 'react';
3
+ import { ReactNode, ComponentPropsWithoutRef, JSX, ComponentPropsWithRef, MouseEvent, ChangeEvent, ForwardedRef, Ref, JSXElementConstructor, ElementType as ElementType$1 } from 'react';
4
4
  import { LinkProps as LinkProps$1 } from 'react-router-dom';
5
5
  import * as styled_components from 'styled-components';
6
6
  import { DropdownMenuContentProps, DropdownMenuItemProps, DropdownMenuRadioGroupProps, DropdownMenuRadioItemProps, DropdownMenuCheckboxItemProps } from '@radix-ui/react-dropdown-menu';
@@ -515,6 +515,108 @@ declare const Ellipsis: {
515
515
  displayName: string;
516
516
  };
517
517
 
518
+ type ActionCallback<T> = (data: T, nextData: T) => Promise<T> | T;
519
+ type Action = (data: FormData | null) => Promise<void>;
520
+ type FormActionState<T> = [{
521
+ data: T;
522
+ error: Error | null;
523
+ }, Action, boolean];
524
+ declare const useFormState: <T extends object>(action: ActionCallback<T>, initialData?: Partial<T>) => FormActionState<T>;
525
+
526
+ type ValidationCallback<T> = (data: T) => FormErrors<T>;
527
+ type FormWithLabelledByProps = {
528
+ 'aria-label'?: never;
529
+ /**
530
+ * The id of the element that labels the form. Typically a heading.
531
+ */
532
+ 'aria-labelledby': string;
533
+ };
534
+ type FormWithLabelProps = {
535
+ /**
536
+ * Accessible name of the form. Use this only when a visible label is not possible. If the form has a title or heading, use `aria-labelledby` instead.
537
+ */
538
+ 'aria-label': string;
539
+ 'aria-labelledby'?: never;
540
+ };
541
+ type FormErrors<T> = Partial<{
542
+ [K in keyof T]: string[] | string;
543
+ }>;
544
+ type FormProps<T> = Omit<ComponentPropsWithoutRef<'form'>, 'action' | 'aria-label' | 'aria-labelledby' | 'children'> & {
545
+ /**
546
+ * The action to be performed when the form is submitted. It can be asynchronous.
547
+ */
548
+ action?: Action;
549
+ /**
550
+ * The form elements used in the form
551
+ */
552
+ children: ReactNode;
553
+ /**
554
+ * An object that providesd errors for the form fields. This is created by `useFormState` and passed along to `FormField`s.
555
+ */
556
+ errors?: FormErrors<T>;
557
+ /**
558
+ * If true, fills the entire container
559
+ */
560
+ fullWidth?: boolean;
561
+ /**
562
+ * The function for handling validation.
563
+ */
564
+ validate?: ValidationCallback<T>;
565
+ /**
566
+ * An object that provides valuesfor the form fields. This is typically the `state.data` value from `useFormState` and passed along to `FormField`s.
567
+ */
568
+ values?: T;
569
+ } & (FormWithLabelledByProps | FormWithLabelProps);
570
+ /**
571
+ * x
572
+ */
573
+ declare const FormComponent: {
574
+ <T>({ children, action, values, validate, fullWidth, ...props }: FormProps<T>, forwardedRef?: Ref<HTMLFormElement>): JSX.Element;
575
+ displayName: string;
576
+ };
577
+ declare const Form: <T>(props: FormProps<T> & {
578
+ ref?: ForwardedRef<HTMLUListElement>;
579
+ }) => ReturnType<typeof FormComponent>;
580
+
581
+ type FormErrorSummaryProps = {
582
+ description: string;
583
+ };
584
+ declare const FormErrorSummary: ({ description }: FormErrorSummaryProps) => react_jsx_runtime.JSX.Element | null;
585
+
586
+ type FormFieldProps = ComponentPropsWithoutRef<'div'> & {
587
+ /**
588
+ * This should be a single child that is a valid form field (or can pretend to be one).
589
+ */
590
+ children: JSX.Element;
591
+ /**
592
+ * Valid label text
593
+ */
594
+ label: ReactNode;
595
+ /**
596
+ * If an id isn't supplied, one is generated internally.
597
+ */
598
+ id?: string;
599
+ /**
600
+ * Will show an error message and put the child input into an invalid state
601
+ */
602
+ error?: ReactNode;
603
+ /**
604
+ * The name attribute of the field. It will map to the form data passed into `useFormState`.
605
+ */
606
+ name: string;
607
+ /**
608
+ * A value that overrides the basic value. This should pair with `onChange`.
609
+ */
610
+ value?: string;
611
+ };
612
+ /**
613
+ * Component description goes here
614
+ */
615
+ declare const FormField: {
616
+ ({ children, label, name, error, value, ...props }: FormFieldProps): JSX.Element;
617
+ displayName: string;
618
+ };
619
+
518
620
  type ExtendedProps<Props = Record<string, unknown>, OverrideProps = Record<string, unknown>> = Omit<Props, keyof OverrideProps> & OverrideProps;
519
621
  type ElementType = JSXElementConstructor<any> | keyof JSX.IntrinsicElements;
520
622
  type PropsOf<C extends ElementType> = JSX.LibraryManagedAttributes<C, ComponentPropsWithoutRef<C>>;
@@ -1366,6 +1468,8 @@ declare const RadioMenuItem: {
1366
1468
  };
1367
1469
 
1368
1470
  type CheckboxMenuItemProps = DropdownMenuCheckboxItemProps & MenuItemButtonProps & {
1471
+ /** Callback to fire when the checked status changes */
1472
+ onCheckedChange: (checked: boolean) => void;
1369
1473
  /**
1370
1474
  * an [Icon](?path=/docs/components-icon--docs) to use as the indicator that the radio item is selected
1371
1475
  */
@@ -1388,7 +1492,7 @@ type CheckboxMenuItemProps = DropdownMenuCheckboxItemProps & MenuItemButtonProps
1388
1492
  ref?: never;
1389
1493
  };
1390
1494
  declare const CheckboxMenuItem: {
1391
- ({ onSelect, checked, onCheckedChange, indicator, ...props }: CheckboxMenuItemProps): react_jsx_runtime.JSX.Element;
1495
+ ({ onSelect, checked, onCheckedChange, ...props }: CheckboxMenuItemProps): react_jsx_runtime.JSX.Element;
1392
1496
  displayName: string;
1393
1497
  };
1394
1498
 
@@ -1404,7 +1508,7 @@ type RadioProps = ComponentPropsWithoutRef<'input'> & {
1404
1508
  /**
1405
1509
  * Indicates that there is an error with the input
1406
1510
  */
1407
- hasError?: boolean;
1511
+ 'aria-invalid'?: boolean;
1408
1512
  /**
1409
1513
  * Provides an ID for the input
1410
1514
  */
@@ -1447,7 +1551,7 @@ declare const Radio: react.ForwardRefExoticComponent<Omit<react.DetailedHTMLProp
1447
1551
  /**
1448
1552
  * Indicates that there is an error with the input
1449
1553
  */
1450
- hasError?: boolean;
1554
+ 'aria-invalid'?: boolean;
1451
1555
  /**
1452
1556
  * Provides an ID for the input
1453
1557
  */
@@ -1660,4 +1764,42 @@ declare const WistiaLogo: {
1660
1764
  displayName: string;
1661
1765
  };
1662
1766
 
1663
- export { Avatar, type AvatarInstanceType, type AvatarProps, Badge, type BadgeProps, Box, type BoxProps, Button, ButtonGroup, type ButtonProps, Checkbox, CheckboxMenuItem, type ColorSchemeTypes, ColorSchemeWrapper, type ColorSchemeWrapperProps, Divider, Ellipsis, Heading, type HeadingProps, Icon, IconButton, type IconButtonProps, type IconNameType, Label, type LabelProps, Link, type LinkProps, Menu, MenuItem, MenuItemDescription, MenuItemLabel, MenuLabel, MenuRadioGroup, Radio, RadioMenuItem, type RadioProps, ScreenReaderOnly, Stack, SubMenu, Tag, type TagProps, Text, type TextProps, Tooltip, type TooltipProps, UIProvider, WistiaLogo, colorSchemeOptions, copyToClipboard, ellipsisFlexParentStyle, ellipsisStyle, iconSizeMap, mq, useActiveMq, useAriaLive, useMq, useWindowSize };
1767
+ type FormGroupProps = Omit<ComponentPropsWithoutRef<'fieldset'>, 'onChange'> & {
1768
+ children: ReactNode;
1769
+ label?: ReactNode;
1770
+ };
1771
+ /**
1772
+ * For grouping like form elements together.
1773
+ */
1774
+ declare const FormGroup: {
1775
+ ({ children, label, ...props }: FormGroupProps): JSX.Element;
1776
+ displayName: string;
1777
+ };
1778
+
1779
+ type RadioGroupProps = FormGroupProps & {
1780
+ onChange?: ((event: ChangeEvent<HTMLInputElement>) => void) | undefined;
1781
+ value?: string | undefined;
1782
+ name?: string | undefined;
1783
+ };
1784
+ /**
1785
+ * For grouping like form elements togtether. Can serve as a checkbox
1786
+ */
1787
+ declare const RadioGroup: {
1788
+ ({ children, name, onChange, value, ...props }: RadioGroupProps): JSX.Element;
1789
+ displayName: string;
1790
+ };
1791
+
1792
+ type CheckboxGroupProps = FormGroupProps & {
1793
+ onChange?: ((event: ChangeEvent<HTMLInputElement>) => void) | undefined;
1794
+ value?: string | undefined;
1795
+ name?: string | undefined;
1796
+ };
1797
+ /**
1798
+ * For grouping like form elements togtether. Can serve as a checkbox
1799
+ */
1800
+ declare const CheckboxGroup: {
1801
+ ({ children, name, onChange, value, ...props }: CheckboxGroupProps): JSX.Element;
1802
+ displayName: string;
1803
+ };
1804
+
1805
+ export { Avatar, type AvatarInstanceType, type AvatarProps, Badge, type BadgeProps, Box, type BoxProps, Button, ButtonGroup, type ButtonProps, Checkbox, CheckboxGroup, CheckboxMenuItem, type ColorSchemeTypes, ColorSchemeWrapper, type ColorSchemeWrapperProps, Divider, Ellipsis, Form, FormErrorSummary, FormField, type FormFieldProps, FormGroup, type FormGroupProps, type FormProps, Heading, type HeadingProps, Icon, IconButton, type IconButtonProps, type IconNameType, Label, type LabelProps, Link, type LinkProps, Menu, MenuItem, MenuItemDescription, MenuItemLabel, MenuLabel, MenuRadioGroup, Radio, RadioGroup, RadioMenuItem, type RadioProps, ScreenReaderOnly, Stack, SubMenu, Tag, type TagProps, Text, type TextProps, Tooltip, type TooltipProps, UIProvider, WistiaLogo, colorSchemeOptions, copyToClipboard, ellipsisFlexParentStyle, ellipsisStyle, iconSizeMap, mq, useActiveMq, useAriaLive, useFormState, useMq, useWindowSize };