|
| 1 | +import React from 'react'; |
| 2 | + |
| 3 | +import { UUIComponentNames } from './components/UUIComponentNames'; |
| 4 | +import type { AccordionProps } from './components/Accordion/Accordion'; |
| 5 | +import type { AccordionPaneProps } from './components/Accordion/AccordionPane'; |
| 6 | +import type { BreadcrumbProps } from './components/Breadcrumb/Breadcrumb'; |
| 7 | +import type { ButtonProps } from './components/Button/Button'; |
| 8 | +import type { CascaderProps } from './components/Cascader/Cascader'; |
| 9 | +import type { CheckboxProps } from './components/Checkbox/Checkbox'; |
| 10 | +import type { CollapseProps } from './components/Collapse/Collapse'; |
| 11 | +import type { DatePickerProps } from './components/DatePicker/DatePicker'; |
| 12 | +import type { DialogProps } from './components/Dialog/Dialog'; |
| 13 | +import type { DrawerProps } from './components/Drawer/Drawer'; |
| 14 | +import type { IconProps } from './components/Icon/Icon'; |
| 15 | +import type { TextFieldProps } from './components/Input/TextField'; |
| 16 | +import type { NumberFieldProps } from './components/Input/NumberField'; |
| 17 | +import type { TextAreaProps } from './components/Input/TextArea'; |
| 18 | +import type { CountdownLabelProps } from './components/Label/CountdownLabel'; |
| 19 | +import type { DateLabelProps } from './components/Label/DateLabel'; |
| 20 | +import type { MoneyLabelProps } from './components/Label/MoneyLabel'; |
| 21 | +import type { NumberAbbrLabelProps } from './components/Label/NumberAbbrLabel'; |
| 22 | +import type { TimeLabelProps } from './components/Label/TimeLabel'; |
| 23 | +import type { LayoutProps } from './components/Layout/Layout'; |
| 24 | +import type { LayoutAsideProps } from './components/Layout/LayoutAside'; |
| 25 | +import type { LayoutFooterProps } from './components/Layout/LayoutFooter'; |
| 26 | +import type { LayoutHeaderProps } from './components/Layout/LayoutHeader'; |
| 27 | +import type { LayoutMainProps } from './components/Layout/LayoutMain'; |
| 28 | +import type { LayoutNavProps } from './components/Layout/LayoutNav'; |
| 29 | +import type { ListBoxProps } from './components/ListBox/ListBox'; |
| 30 | +import type { LoadingCoverProps } from './components/Loading/LoadingCover'; |
| 31 | +import type { LoadingSpinnerProps } from './components/Loading/LoadingSpinner'; |
| 32 | +import type { PageProps } from './components/Page/Page'; |
| 33 | +import type { PageAnnotatedSectionProps } from './components/Page/PageAnnotatedSection'; |
| 34 | +import type { PageSectionProps } from './components/Page/PageSection'; |
| 35 | +import type { PaginationProps } from './components/Pagination/Pagination'; |
| 36 | +import type { PageInfoProps } from './components/Pagination/PageInfo'; |
| 37 | +import type { PageJumperProps } from './components/Pagination/PageJumper'; |
| 38 | +import type { PageListProps } from './components/Pagination/PageList'; |
| 39 | +import type { PageNextButtonProps } from './components/Pagination/PageNextButton'; |
| 40 | +import type { PagePrevButtonProps } from './components/Pagination/PagePrevButton'; |
| 41 | +import type { PageSelectorProps } from './components/Pagination/PageSelector'; |
| 42 | +import type { PageSizeProps } from './components/Pagination/PageSize'; |
| 43 | +import type { PopoverProps } from './components/Popover/Popover'; |
| 44 | +import type { ProgressBarProps } from './components/ProgressBar/ProgressBar'; |
| 45 | +import type { RadioProps } from './components/Radio/Radio'; |
| 46 | +import type { RadioGroupProps } from './components/Radio/RadioGroup'; |
| 47 | +import type { SegmentControlProps } from './components/SegmentControl/SegmentControl'; |
| 48 | +import type { HTMLSelectProps } from './components/Select/HTMLSelect'; |
| 49 | +import type { SelectProps } from './components/Select/Select'; |
| 50 | +import type { SkeletonProps } from './components/Skeleton/Skeleton'; |
| 51 | +import type { SkeletonParagraphProps } from './components/Skeleton/Paragraph'; |
| 52 | +import type { SkeletonPictureProps } from './components/Skeleton/Picture'; |
| 53 | +import type { SkeletonTitleProps } from './components/Skeleton/Title'; |
| 54 | +import type { SliderProps } from './components/Slider/Slider'; |
| 55 | +import type { StepperProps } from './components/Stepper/Stepper'; |
| 56 | +import type { SwitchProps } from './components/Switch/Switch'; |
| 57 | +import type { TableProps } from './components/Table/Table'; |
| 58 | +import type { TabsProps } from './components/Tabs/Tabs'; |
| 59 | +import type { TabProps } from './components/Tabs/Tab'; |
| 60 | +import type { TagProps } from './components/Tag/Tag'; |
| 61 | +import type { ToastProps } from './components/Toast/Toast'; |
| 62 | +import type { ToasterProps } from './components/Toast/Toaster'; |
| 63 | + |
| 64 | + |
| 65 | +export interface UUIProviderCustomize { |
| 66 | + [UUIComponentNames.Accordion]?: AccordionProps['customize']; |
| 67 | + [UUIComponentNames.AccordionPane]?: AccordionPaneProps['customize']; |
| 68 | + [UUIComponentNames.Breadcrumb]?: BreadcrumbProps['customize']; |
| 69 | + [UUIComponentNames.Button]?: ButtonProps['customize']; |
| 70 | + [UUIComponentNames.Cascader]?: CascaderProps['customize']; |
| 71 | + [UUIComponentNames.Checkbox]?: CheckboxProps['customize']; |
| 72 | + [UUIComponentNames.Collapse]?: CollapseProps['customize']; |
| 73 | + [UUIComponentNames.DatePicker]?: DatePickerProps['customize']; |
| 74 | + [UUIComponentNames.Dialog]?: DialogProps['customize']; |
| 75 | + [UUIComponentNames.Drawer]?: DrawerProps['customize']; |
| 76 | + [UUIComponentNames.Icon]?: IconProps['customize']; |
| 77 | + [UUIComponentNames.TextField]?: TextFieldProps['customize']; |
| 78 | + [UUIComponentNames.NumberField]?: NumberFieldProps['customize']; |
| 79 | + [UUIComponentNames.TextArea]?: TextAreaProps['customize']; |
| 80 | + [UUIComponentNames.CountdownLabel]?: CountdownLabelProps['customize']; |
| 81 | + [UUIComponentNames.DateLabel]?: DateLabelProps['customize']; |
| 82 | + [UUIComponentNames.MoneyLabel]?: MoneyLabelProps['customize']; |
| 83 | + [UUIComponentNames.NumberAbbrLabel]?: NumberAbbrLabelProps['customize']; |
| 84 | + [UUIComponentNames.TimeLabel]?: TimeLabelProps['customize']; |
| 85 | + [UUIComponentNames.Layout]?: LayoutProps['customize']; |
| 86 | + [UUIComponentNames.LayoutAside]?: LayoutAsideProps['customize']; |
| 87 | + [UUIComponentNames.LayoutFooter]?: LayoutFooterProps['customize']; |
| 88 | + [UUIComponentNames.LayoutHeader]?: LayoutHeaderProps['customize']; |
| 89 | + [UUIComponentNames.LayoutMain]?: LayoutMainProps['customize']; |
| 90 | + [UUIComponentNames.LayoutNav]?: LayoutNavProps['customize']; |
| 91 | + [UUIComponentNames.ListBox]?: ListBoxProps['customize']; |
| 92 | + [UUIComponentNames.LoadingCover]?: LoadingCoverProps['customize']; |
| 93 | + [UUIComponentNames.LoadingSpinner]?: LoadingSpinnerProps['customize']; |
| 94 | + [UUIComponentNames.Page]?: PageProps['customize']; |
| 95 | + [UUIComponentNames.PageAnnotatedSection]?: PageAnnotatedSectionProps['customize']; |
| 96 | + [UUIComponentNames.PageSection]?: PageSectionProps['customize']; |
| 97 | + [UUIComponentNames.Pagination]?: PaginationProps['customize']; |
| 98 | + [UUIComponentNames.PageInfo]?: PageInfoProps['customize']; |
| 99 | + [UUIComponentNames.PageJumper]?: PageJumperProps['customize']; |
| 100 | + [UUIComponentNames.PageList]?: PageListProps['customize']; |
| 101 | + [UUIComponentNames.PageNextButton]?: PageNextButtonProps['customize']; |
| 102 | + [UUIComponentNames.PagePrevButton]?: PagePrevButtonProps['customize']; |
| 103 | + [UUIComponentNames.PageSelector]?: PageSelectorProps['customize']; |
| 104 | + [UUIComponentNames.PageSize]?: PageSizeProps['customize']; |
| 105 | + [UUIComponentNames.Popover]?: PopoverProps['customize']; |
| 106 | + [UUIComponentNames.ProgressBar]?: ProgressBarProps['customize']; |
| 107 | + [UUIComponentNames.Radio]?: RadioProps['customize']; |
| 108 | + [UUIComponentNames.RadioGroup]?: RadioGroupProps['customize']; |
| 109 | + [UUIComponentNames.SegmentControl]?: SegmentControlProps['customize']; |
| 110 | + [UUIComponentNames.HTMLSelect]?: HTMLSelectProps['customize']; |
| 111 | + [UUIComponentNames.Select]?: SelectProps['customize']; |
| 112 | + [UUIComponentNames.Skeleton]?: SkeletonProps['customize']; |
| 113 | + [UUIComponentNames.SkeletonParagraph]?: SkeletonParagraphProps['customize']; |
| 114 | + [UUIComponentNames.SkeletonPicture]?: SkeletonPictureProps['customize']; |
| 115 | + [UUIComponentNames.SkeletonTitle]?: SkeletonTitleProps['customize']; |
| 116 | + [UUIComponentNames.Slider]?: SliderProps['customize']; |
| 117 | + [UUIComponentNames.Stepper]?: StepperProps['customize']; |
| 118 | + [UUIComponentNames.Switch]?: SwitchProps['customize']; |
| 119 | + [UUIComponentNames.Table]?: TableProps['customize']; |
| 120 | + [UUIComponentNames.Tabs]?: TabsProps['customize']; |
| 121 | + [UUIComponentNames.Tab]?: TabProps['customize']; |
| 122 | + [UUIComponentNames.Tag]?: TagProps['customize']; |
| 123 | + [UUIComponentNames.Toast]?: ToastProps['customize']; |
| 124 | + [UUIComponentNames.Toaster]?: ToasterProps['customize']; |
| 125 | +} |
| 126 | + |
| 127 | +export type UUIProviderExtraCustomizeT = { [key: string]: any } |
| 128 | + |
| 129 | +export interface UUIProviderContextValue<C extends UUIProviderExtraCustomizeT> { |
| 130 | + customize?: C & UUIProviderCustomize; |
| 131 | + options?: { |
| 132 | + prefix?: string; |
| 133 | + separator?: string; |
| 134 | + }; |
| 135 | +} |
| 136 | +export const UUIProviderContext = React.createContext<UUIProviderContextValue<any> | null>(null) |
| 137 | + |
| 138 | +export interface UUIProviderProps<C extends UUIProviderExtraCustomizeT> extends UUIProviderContextValue<C> { |
| 139 | + children: React.ReactNode; |
| 140 | +} |
| 141 | +export function UUIProvider<C extends UUIProviderExtraCustomizeT>(props: UUIProviderProps<C>) { |
| 142 | + return ( |
| 143 | + <UUIProviderContext.Provider value={{ |
| 144 | + customize: props.customize, |
| 145 | + options: props.options, |
| 146 | + }}> |
| 147 | + {props.children} |
| 148 | + </UUIProviderContext.Provider> |
| 149 | + ); |
| 150 | +} |
0 commit comments