index int64 0 0 | repo_id stringlengths 16 181 | file_path stringlengths 28 270 | content stringlengths 1 11.6M | __index_level_0__ int64 0 10k |
|---|---|---|---|---|
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/__workshop__/_common | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/__workshop__/_common/schema/simpleFieldGroupSchema.ts | import {CogIcon} from '@sanity/icons'
import {WorkshopSchemaProps, wrapSchema} from '../data'
export default function getSchema(props: WorkshopSchemaProps) {
const {hiddenGroup = false} = props
return wrapSchema({
name: 'dummy',
title: 'Basic groups',
type: 'document',
groups: [
{
na... | 3,000 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/components/Alert.tsx | import {ErrorOutlineIcon, WarningOutlineIcon} from '@sanity/icons'
import {Box, Card, Flex, Text} from '@sanity/ui'
import React, {ComponentProps} from 'react'
import styled from 'styled-components'
interface AlertProps extends Omit<ComponentProps<typeof Card>, 'title'> {
title: React.ReactNode
status?: 'warning' ... | 3,001 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/components/AlertStrip.tsx | import {ErrorOutlineIcon, WarningOutlineIcon, InfoOutlineIcon} from '@sanity/icons'
import {Box, Card, CardProps, Flex} from '@sanity/ui'
import React from 'react'
import {Details} from './Details'
interface AlertProps extends Omit<CardProps, 'title'> {
title: React.ReactNode
status?: 'warning' | 'error' | 'info'
... | 3,002 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/components/Details.tsx | import {ToggleArrowRightIcon} from '@sanity/icons'
import {Box, Flex, Inline, Text} from '@sanity/ui'
import React, {useCallback, useEffect, useState} from 'react'
import styled from 'styled-components'
interface DetailsProps {
children?: React.ReactNode
margin?: number | number[]
marginX?: number | number[]
m... | 3,003 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/components/EditPortal.tsx | import React, {type ReactNode, useState, useRef} from 'react'
import {Box, Dialog, ResponsiveWidthProps} from '@sanity/ui'
import {PresenceOverlay} from '../../presence'
import {PopoverDialog} from '../../components'
import {VirtualizerScrollInstanceProvider} from '../inputs/arrays/ArrayOfObjectsInput/List/VirtualizerS... | 3,004 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/components/FormInput.tsx | import React, {memo, useCallback, useMemo} from 'react'
import {isEqual, startsWith, trimLeft} from '@sanity/util/paths'
import {isKeySegment, Path} from '@sanity/types'
import {FieldMember} from '../store'
import {
ArrayOfObjectsInputProps,
ObjectInputProps,
RenderAnnotationCallback,
RenderArrayOfObjectsItemCa... | 3,005 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/components/FullscreenSpinner.tsx | import {Flex, Layer, Spinner} from '@sanity/ui'
import React from 'react'
import styled from 'styled-components'
const FullscreenLayer = styled(Layer)`
position: absolute;
width: 100%;
height: 100%;
top: 0;
`
export function FullscreenSpinner() {
return (
<FullscreenLayer>
<Flex height="fill" alig... | 3,006 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/components/SpinnerWithText.tsx | import {Box, Flex, Spinner, Text} from '@sanity/ui'
import React from 'react'
export function SpinnerWithText(props: {text: string}) {
const {text} = props
return (
<Flex direction="row" justify="center" align="center">
<Spinner />
<Box marginLeft={2}>
<Text>{text}</Text>
</Box>
... | 3,007 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/components/index.ts | export * from './FormInput'
export * from './formField'
| 3,008 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/components/ActivateOnFocus/ActivateOnFocus.styles.tsx | import styled from 'styled-components'
import {Card, Flex} from '@sanity/ui'
export const OverlayContainer = styled.div`
position: relative;
`
export const ContentContainer = styled.div`
z-index: 13;
opacity: 0;
transition: opacity 300ms linear;
`
export const CardContainer = styled(Card)`
border: 1px soli... | 3,009 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/components/ActivateOnFocus/ActivateOnFocus.tsx | // This is transitional in order to track usage of the ActivateOnFocusPart part from within the form-builder package
import React, {KeyboardEvent, useCallback, useMemo, useState} from 'react'
import {Text} from '@sanity/ui'
import {
OverlayContainer,
FlexContainer,
CardContainer,
ContentContainer,
} from './Act... | 3,010 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/components/formField/FormField.tsx | import {FormNodeValidation} from '@sanity/types'
import {Stack} from '@sanity/ui'
import React, {memo} from 'react'
import {FormNodePresence} from '../../../presence'
import {DocumentFieldActionNode} from '../../../config'
import {useFieldActions} from '../../field'
import {FieldCommentsProps} from '../../types'
import... | 3,011 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/components/formField/FormFieldBaseHeader.tsx | import React, {useCallback, useEffect, useMemo, useState} from 'react'
import styled, {css} from 'styled-components'
import {
Box,
Card,
Flex,
Theme,
TooltipDelayGroupProvider,
TooltipDelayGroupProviderProps,
} from '@sanity/ui'
import {FieldPresence, FormNodePresence} from '../../../presence'
import {Docum... | 3,012 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/components/formField/FormFieldHeaderText.tsx | /* eslint-disable camelcase */
import {FormNodeValidation} from '@sanity/types'
import {Box, Flex, Stack, Text} from '@sanity/ui'
import React, {memo} from 'react'
import {createDescriptionId} from '../../members/common/createDescriptionId'
import {FormFieldValidationStatus} from './FormFieldValidationStatus'
/** @in... | 3,013 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/components/formField/FormFieldSet.tsx | /* eslint-disable camelcase */
import {Box, Flex, Grid, rem, Stack, Text, Theme, useForwardedRef} from '@sanity/ui'
import React, {forwardRef, useCallback, useMemo} from 'react'
import styled, {css} from 'styled-components'
import {FormNodeValidation} from '@sanity/types'
import {FormNodePresence} from '../../../presen... | 3,014 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/components/formField/FormFieldSetLegend.tsx | import {Box, Flex, rem, Text, Theme} from '@sanity/ui'
import React, {memo} from 'react'
import {ToggleArrowRightIcon} from '@sanity/icons'
import styled, {css} from 'styled-components'
import {focusRingStyle} from './styles'
export interface FormFieldSetLegendProps {
collapsed: boolean
collapsible?: boolean
onC... | 3,015 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/components/formField/FormFieldStatus.tsx | import React from 'react'
import styled from 'styled-components'
/** @internal */
export interface FieldStatusProps {
children?: React.ReactNode
maxAvatars?: number
position?: 'top' | 'bottom'
}
const Root = styled.div`
display: flex;
justify-content: flex-end;
box-sizing: border-box;
min-height: var(--... | 3,016 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/components/formField/FormFieldValidationStatus.tsx | /* eslint-disable camelcase */
import {hues} from '@sanity/color'
import {ErrorOutlineIcon, InfoOutlineIcon, WarningOutlineIcon} from '@sanity/icons'
import {FormNodeValidation} from '@sanity/types'
import {Box, Flex, Placement, Stack, Text, Tooltip} from '@sanity/ui'
import React, {useMemo} from 'react'
import styled... | 3,017 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/components/formField/index.ts | export * from './FormField'
export * from './FormFieldHeaderText'
export * from './FormFieldSet'
export * from './FormFieldStatus'
export * from './FormFieldValidationStatus'
export * from './types'
| 3,018 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/components/formField/styles.ts | function focusRingBorderStyle(border: {color: string; width: number}): string {
return `inset 0 0 0 ${border.width}px ${border.color}`
}
export function focusRingStyle(opts: {
base?: {bg: string}
border?: {color: string; width: number}
focusRing: {offset: number; width: number}
}): string {
const {base, bord... | 3,019 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/components/formField/types.ts | /** @internal */
export interface FormFieldValidationWarning {
type: 'warning'
label: string
}
/** @internal */
export interface FormFieldValidationError {
type: 'error'
label: string
}
/** @internal */
export interface FormFieldValidationInfo {
type: 'info'
label: string
}
/** @internal */
export type F... | 3,020 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/components/formField | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/components/formField/__workshop__/example.tsx | import {ValidationMarker} from '@sanity/types'
import {Card, Code, Container, Flex, LayerProvider} from '@sanity/ui'
import {useBoolean, useNumber, useString} from '@sanity/ui-workshop'
import React, {useCallback, useMemo, useState} from 'react'
import {FormNodePresence} from '../../../../presence'
import {useCurrentUs... | 3,021 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/components/formField | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/components/formField/__workshop__/index.ts | import {defineScope} from '@sanity/ui-workshop'
import {lazy} from 'react'
export default defineScope({
name: 'core/form/form-field',
title: 'FormField',
stories: [
{
name: 'example',
title: 'Example',
component: lazy(() => import('./example')),
},
],
})
| 3,022 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/components/tagInput/index.ts | export * from './tagInput'
| 3,023 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/components/tagInput/styles.ts | export function focusRingBorderStyle(border: {color: string; width: number}): string {
return `inset 0 0 0 ${border.width}px ${border.color}`
}
export function focusRingStyle(opts: {
base?: {bg: string}
border?: {color: string; width: number}
focusRing: {offset: number; width: number}
}): string {
const {bas... | 3,024 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/components/tagInput/tagInput.tsx | import {CloseIcon} from '@sanity/icons'
import {
Box,
Button,
Card,
CSSObject,
Flex,
isHTMLElement,
rem,
Text,
Theme,
useForwardedRef,
} from '@sanity/ui'
import React, {forwardRef, useCallback, useEffect, useMemo, useRef, useState} from 'react'
import styled, {css} from 'styled-components'
import {... | 3,025 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/components/withFocusRing/helpers.ts | // todo: get these utils from @sanity/ui instead
export function focusRingBorderStyle(border: {color: string; width: number}): string {
return `inset 0 0 0 ${border.width}px ${border.color}`
}
export function focusRingStyle(opts: {
base?: {bg: string}
border?: {color: string; width: number}
focusRing: {offset:... | 3,026 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/components/withFocusRing/index.ts | export * from './withFocusRing'
| 3,027 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/components/withFocusRing/withFocusRing.ts | import styled, {css} from 'styled-components'
import {rem, Theme} from '@sanity/ui'
import {ComponentType} from 'react'
import {focusRingBorderStyle, focusRingStyle} from './helpers'
export function withFocusRing<Props>(component: ComponentType<Props>) {
return styled(component)<Props & {$border?: boolean}>(
(pr... | 3,028 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/field/HoveredFieldContext.ts | import {createContext} from 'react'
import {Path} from '@sanity/types'
/** @internal */
export interface HoveredFieldContextValue {
hoveredStack: string[]
onMouseEnter: (path: Path) => void
onMouseLeave: (path: Path) => void
}
/** @internal */
export const HoveredFieldContext = createContext<HoveredFieldContext... | 3,029 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/field/HoveredFieldProvider.tsx | import {Path} from '@sanity/types'
import React, {PropsWithChildren, useCallback, useMemo, useState} from 'react'
import {pathToString} from '../../field'
import {HoveredFieldContext, HoveredFieldContextValue} from './HoveredFieldContext'
/** @internal */
export function HoveredFieldProvider(props: PropsWithChildren) ... | 3,030 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/field/index.ts | export * from './actions'
export * from './HoveredFieldProvider'
export * from './useHoveredField'
| 3,031 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/field/useHoveredField.ts | import {useContext} from 'react'
import {HoveredFieldContext, HoveredFieldContextValue} from './HoveredFieldContext'
/** @internal */
export function useHoveredField(): HoveredFieldContextValue {
return useContext(HoveredFieldContext)
}
| 3,032 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/field | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/field/actions/FieldActionMenu.tsx | /* eslint-disable react/jsx-handler-names */
import {EllipsisVerticalIcon} from '@sanity/icons'
import {Card, Menu, MenuButton, MenuButtonProps} from '@sanity/ui'
import React, {memo, useCallback, useId, useMemo, useState} from 'react'
import {StatusButton, StatusButtonProps} from '../../../components'
import {Documen... | 3,033 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/field | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/field/actions/FieldActionMenuGroup.tsx | import {Box, Label, MenuGroup, MenuGroupProps} from '@sanity/ui'
import React from 'react'
import {DocumentFieldActionGroup} from '../../../config'
import {FieldActionMenuNode} from './FieldActionMenuNode'
const POPOVER_PROPS: MenuGroupProps['popover'] = {
placement: 'right',
fallbackPlacements: ['top', 'bottom'],... | 3,034 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/field | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/field/actions/FieldActionMenuItem.tsx | import {MenuItem, Text} from '@sanity/ui'
import React, {useCallback} from 'react'
import {CheckmarkIcon} from '@sanity/icons'
import {TooltipOfDisabled} from '../../../components'
import {DocumentFieldActionItem} from '../../../config'
export function FieldActionMenuItem(props: {action: DocumentFieldActionItem}) {
... | 3,035 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/field | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/field/actions/FieldActionMenuNode.tsx | import {MenuDivider} from '@sanity/ui'
import React from 'react'
import {DocumentFieldActionNode} from '../../../config'
import {FieldActionMenuItem} from './FieldActionMenuItem'
import {FieldActionMenuGroup} from './FieldActionMenuGroup'
interface FieldActionMenuNodeProps {
action: DocumentFieldActionNode
isFirst... | 3,036 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/field | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/field/actions/FieldActionsContext.ts | import {createContext} from 'react'
import {DocumentFieldActionNode} from '../../../config'
/** @internal */
export interface FieldActionsContextValue {
actions: DocumentFieldActionNode[]
focused?: boolean
hovered: boolean
onMouseEnter: () => void
onMouseLeave: () => void
}
/** @internal */
export const Fie... | 3,037 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/field | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/field/actions/FieldActionsProvider.tsx | import React, {PropsWithChildren, useCallback, useMemo} from 'react'
import {Path} from '@sanity/types'
import {DocumentFieldActionNode} from '../../../config'
import {pathToString} from '../../../field'
import {supportsTouch} from '../../../util'
import {useHoveredField} from '../useHoveredField'
import {FieldActionsC... | 3,038 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/field | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/field/actions/FieldActionsResolver.tsx | import {Path, SchemaType} from '@sanity/types'
import React, {memo, useCallback, useEffect, useRef, useState} from 'react'
import {DocumentFieldAction, DocumentFieldActionNode} from '../../../config'
import {useUnique} from '../../../util'
import {filterActions} from './helpers'
/** @internal */
export interface Field... | 3,039 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/field | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/field/actions/helpers.ts | import {DocumentFieldActionNode} from '../../../config'
export function filterActions(actions: DocumentFieldActionNode[]): DocumentFieldActionNode[] {
return actions
.filter(Boolean)
.filter((node) => {
if ('hidden' in node) return node.hidden !== true
return true
})
.map((node) => {
... | 3,040 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/field | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/field/actions/index.ts | export * from './FieldActionMenu'
export * from './FieldActionsResolver'
export * from './FieldActionsProvider'
export * from './useFieldActions'
| 3,041 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/field | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/field/actions/useFieldActions.ts | import {useContext} from 'react'
import {FieldActionsContext, FieldActionsContextValue} from './FieldActionsContext'
/** @internal */
export function useFieldActions(): FieldActionsContextValue {
return useContext(FieldActionsContext)
}
| 3,042 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/form-components-hooks/componentHooks.ts | import {ComponentType} from 'react'
import {useMiddlewareComponents} from '../../config/components'
import {BlockAnnotationProps, BlockProps, FieldProps, InputProps, ItemProps} from '../types'
import {PreviewProps} from '../../components'
import {
DefaultAnnotation,
DefaultBlock,
DefaultField,
DefaultInlineBloc... | 3,043 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/form-components-hooks/components.ts | import {SchemaType} from '@sanity/types'
import React, {createElement, useCallback} from 'react'
import {PreviewProps} from '../../components/previews'
import {
defaultResolveInputComponent,
defaultResolvePreviewComponent,
} from '../studio/inputResolver/inputResolver'
import {BlockAnnotationProps, BlockProps, Fiel... | 3,044 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/form-components-hooks/index.ts | export * from './componentHooks'
| 3,045 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/form-components-hooks/picks.ts | import {ComponentType} from 'react'
import {PreviewProps} from '../../components/previews'
import {PluginOptions} from '../../config'
import {BlockAnnotationProps, BlockProps, FieldProps, InputProps, ItemProps} from '../types'
export function pickInputComponent(
plugin: PluginOptions,
): ComponentType<Omit<InputProp... | 3,046 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/hooks/useDidUpdate.ts | import {useEffect} from 'react'
import shallowEquals from 'shallow-equals'
import {usePrevious} from './usePrevious'
/**
* A hook for doing side effects as a response to a change in a hook value between renders
*
* @example
* ```ts
* useDidUpdate(hasFocus, (hadFocus, hasFocus) => {
* if (hasFocus) {
* scrol... | 3,047 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/hooks/useOnClickOutside.ts | import {RefObject, useEffect} from 'react'
// This is a modified version of https://usehooks.com/useOnClickOutside that can take multiple element refs
// There is currently a bug in the `useClickOutside` hook from @sanity/ui that requires the refs to be passed as
// actual HTML elements instead of mutable refs. This r... | 3,048 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/hooks/usePrevious.ts | import {useEffect, useRef} from 'react'
/**
* A hook that returns the previous value of a component variable
* This might be provided by React in the future (https://reactjs.org/docs/hooks-faq.html#how-to-get-the-previous-props-or-state)
*/
export function usePrevious<T>(
/** The value to track. Will return undef... | 3,049 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/hooks/useScrollIntoViewOnFocusWithin.ts | import {useCallback} from 'react'
import scrollIntoView from 'scroll-into-view-if-needed'
import {useDidUpdate} from './useDidUpdate'
/**
* A hook to help make sure the parent element of a value edited in a dialog (or "out of band") stays
visible in the background
* @param elementRef - The element to scroll into vi... | 3,050 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/hooks | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/hooks/__tests__/useDidUpdate.test.ts | /* eslint-disable max-nested-callbacks */
import {renderHook} from '@testing-library/react'
import {StrictMode} from 'react'
import {useDidUpdate} from '../useDidUpdate'
describe('useDidUpdate', () => {
describe('Normal Mode', () => {
it('calls the didUpdate callback when the value changes', () => {
const ... | 3,051 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/hooks | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/hooks/__tests__/useOnClickOutside.test.tsx | import {render, renderHook} from '@testing-library/react'
import React, {createRef} from 'react'
import {useOnClickOutside} from '../useOnClickOutside'
describe('useOnClickOutside', () => {
it('calls the handler when clicking outside of the refs', () => {
const handler = jest.fn()
const ref1 = createRef<HTML... | 3,052 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/hooks | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/hooks/__tests__/usePrevious.test.ts | import {renderHook} from '@testing-library/react'
import {usePrevious} from '../usePrevious'
describe('usePrevious', () => {
it('should return undefined on the first render', () => {
const {result} = renderHook(() => usePrevious('test'))
expect(result.current).toBeNull()
})
it('should return the previou... | 3,053 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/hooks | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/hooks/__tests__/useScrollIntoViewOnFocusWithin.test.ts | import {renderHook} from '@testing-library/react'
import scrollIntoView from 'scroll-into-view-if-needed'
import * as useDidUpdate from '../useDidUpdate'
import {useScrollIntoViewOnFocusWithin} from '../useScrollIntoViewOnFocusWithin'
jest.mock('scroll-into-view-if-needed', () => jest.fn())
describe('useScrollIntoVie... | 3,054 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs/BooleanInput.test.tsx | import userEvent from '@testing-library/user-event'
import {defineField} from '@sanity/types'
import React from 'react'
import {renderBooleanInput} from '../../../../test/form/renderBooleanInput'
import {BooleanInput} from './BooleanInput'
const defs = {
booleanTest: defineField({
name: 'booleanTest',
title:... | 3,055 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs/BooleanInput.tsx | import React from 'react'
import styled from 'styled-components'
import {Box, Card, CardTone, Checkbox, Flex, Switch} from '@sanity/ui'
import {BooleanInputProps} from '../types'
import {FormFieldHeaderText} from '../components/formField/FormFieldHeaderText'
import {FormFieldStatus} from '../components/formField/FormFi... | 3,056 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs/EmailInput.tsx | import React from 'react'
import {TextInput} from '@sanity/ui'
import {StringInputProps} from '../types'
/**
*
* @hidden
* @beta
*/
export type EmailInputProps = StringInputProps
/**
*
* @hidden
* @beta
*/
export function EmailInput(props: EmailInputProps) {
const {validationError, elementProps} = props
r... | 3,057 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs/NumberInput.test.tsx | // eslint-disable-next-line import/no-unassigned-import
import '@testing-library/jest-dom/extend-expect'
import React from 'react'
import {renderNumberInput} from '../../../../test/form'
import {NumberInput} from './NumberInput'
describe('number-input', () => {
it('renders the number input field', async () => {
... | 3,058 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs/NumberInput.tsx | import React from 'react'
import {TextInput} from '@sanity/ui'
import {getValidationRule} from '../utils/getValidationRule'
import {NumberInputProps} from '../types'
/**
*
* @hidden
* @beta
*/
export function NumberInput(props: NumberInputProps) {
const {schemaType, validationError, elementProps} = props
// ... | 3,059 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs/SelectInput.tsx | import {isTitledListValue, TitledListValue} from '@sanity/types'
import {Box, Card, Flex, Inline, Radio, Select, Stack, Text} from '@sanity/ui'
import {capitalize} from 'lodash'
import React, {useId, forwardRef, useCallback, useMemo} from 'react'
import {ChangeIndicator} from '../../changeIndicators'
import {PatchEvent... | 3,060 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs/StringInput.test.tsx | import userEvent from '@testing-library/user-event'
import React from 'react'
import {renderStringInput} from '../../../../test/form/renderStringInput'
import {StringInput} from './StringInput'
describe('StringInput', () => {
it('renders input value', async () => {
const {result} = await renderStringInput({
... | 3,061 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs/StringInput.tsx | import React from 'react'
import {TextInput} from '@sanity/ui'
import {StringInputProps} from '../types'
/**
*
* @hidden
* @beta
*/
export function StringInput(props: StringInputProps) {
const {validationError, elementProps} = props
return <TextInput {...elementProps} customValidity={validationError} data-test... | 3,062 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs/TagsArrayInput.tsx | import React, {useCallback, useMemo} from 'react'
import {set, unset} from '../patch'
import {TagInput} from '../components/tagInput'
import {ArrayOfPrimitivesInputProps} from '../types'
import {ChangeIndicator} from '../../changeIndicators'
/**
*
* @hidden
* @beta
*/
export type TagsArrayInputProps = ArrayOfPrimi... | 3,063 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs/TelephoneInput.tsx | import React from 'react'
import {TextInput} from '@sanity/ui'
import {StringInputProps} from '../types'
/**
*
* @hidden
* @beta
*/
export type TelephoneInputProps = StringInputProps
/**
*
* @hidden
* @beta
*/
export function TelephoneInput(props: TelephoneInputProps) {
const {schemaType, validationError, v... | 3,064 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs/TextInput.tsx | import React from 'react'
import {TextSchemaType} from '@sanity/types'
import {TextArea} from '@sanity/ui'
import styled from 'styled-components'
import {StringInputProps} from '../types'
/**
*
* @hidden
* @beta
*/
export type TextInputProps = StringInputProps<TextSchemaType>
const StyledTextArea = styled(TextAre... | 3,065 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs/UrlInput.tsx | import {TextInput} from '@sanity/ui'
import React from 'react'
import {getValidationRule} from '../utils/getValidationRule'
import {StringInputProps} from '../types'
/**
*
* @hidden
* @beta
*/
export type UrlInputProps = StringInputProps
/**
*
* @hidden
* @beta
*/
export function UrlInput(props: UrlInputProps... | 3,066 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs/index.ts | export type {PortableTextEditorElement} from './PortableText/Compositor'
export * from './files/types'
export * from './PortableText/PortableTextInput'
export {PortableTextInput as BlockEditor} from './PortableText/PortableTextInput'
export * from './arrays/UniversalArrayInput'
export * from './arrays/ArrayOfPrimitive... | 3,067 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs/CrossDatasetReferenceInput/CrossDatasetReferenceInput.tsx | /* eslint-disable complexity, max-nested-callbacks, no-nested-ternary */
import React, {useCallback, useMemo, useRef, useState, useId} from 'react'
import {CrossDatasetReferenceValue, CrossDatasetReferenceSchemaType} from '@sanity/types'
import {EllipsisVerticalIcon, ResetIcon as ClearIcon, SyncIcon as ReplaceIcon} fr... | 3,068 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs/CrossDatasetReferenceInput/CrossDatasetReferencePreview.styled.tsx | import {Flex} from '@sanity/ui'
import styled from 'styled-components'
export const StyledPreviewFlex = styled(Flex)`
/* this is a hack to avoid layout jumps while previews are loading
or the message is not tall enough to fill the card
there's probably better ways of solving this */
min-height: 36px;
`
export... | 3,069 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs/CrossDatasetReferenceInput/CrossDatasetReferencePreview.tsx | import React, {createElement, ReactNode, useMemo} from 'react'
import {CrossDatasetType, PreviewValue} from '@sanity/types'
import {Box, Flex, Inline, Label, Text, Tooltip} from '@sanity/ui'
import {AccessDeniedIcon, HelpCircleIcon, LaunchIcon} from '@sanity/icons'
import imageUrlBuilder from '@sanity/image-url'
import... | 3,070 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs/CrossDatasetReferenceInput/DisabledFeatureWarning.tsx | import {ResetIcon, WarningOutlineIcon} from '@sanity/icons'
import {Card, Flex, Box, Text, Stack, Button} from '@sanity/ui'
import React, {useMemo} from 'react'
import styled from 'styled-components'
import {CrossDatasetReferenceValue} from '@sanity/types'
type Props = {
value?: CrossDatasetReferenceValue
onClearV... | 3,071 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs/CrossDatasetReferenceInput/OptionPreview.tsx | /* eslint-disable max-nested-callbacks,no-nested-ternary */
import React from 'react'
import {CrossDatasetReferenceSchemaType} from '@sanity/types'
import {Stack, TextSkeleton} from '@sanity/ui'
import {Observable} from 'rxjs'
import {Alert} from '../../components/Alert'
import {CrossDatasetReferenceInfo} from './types... | 3,072 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs/CrossDatasetReferenceInput/PreviewReferenceValue.tsx | import React from 'react'
import {CrossDatasetReferenceValue, CrossDatasetReferenceSchemaType} from '@sanity/types'
import {Stack, Text, TextSkeleton} from '@sanity/ui'
import {Loadable} from './useReferenceInfo'
import {CrossDatasetReferenceInfo} from './types'
import {CrossDatasetReferencePreview} from './CrossDatase... | 3,073 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs/CrossDatasetReferenceInput/ReferenceAutocomplete.tsx | import React, {forwardRef, useCallback} from 'react'
import {Autocomplete, Box, Flex, Placement, Popover, Text} from '@sanity/ui'
import styled from 'styled-components'
const StyledPopover = styled(Popover)`
& > div {
overflow: auto;
-webkit-overflow-scrolling: touch;
}
`
const StyledText = styled(Text)`
... | 3,074 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs/CrossDatasetReferenceInput/index.ts | export * from './CrossDatasetReferenceInput'
export * from './types'
| 3,075 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs/CrossDatasetReferenceInput/types.ts | import {PreviewValue} from '@sanity/types'
import {Observable} from 'rxjs'
import {DocumentAvailability} from '../../../preview'
/** @internal */
export interface CrossDatasetReferenceInfo {
id: string
type: string | undefined
availability: DocumentAvailability | null
preview: {
published: PreviewValue | u... | 3,076 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs/CrossDatasetReferenceInput/useReferenceInfo.ts | import {useCallback, useMemo, useState} from 'react'
import {catchError, map, startWith} from 'rxjs/operators'
import {Observable, of} from 'rxjs'
import {useMemoObservable} from 'react-rx'
import {usePrevious} from '../../hooks/usePrevious'
import {CrossDatasetReferenceInfo} from './types'
// eslint-disable-next-line... | 3,077 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs/CrossDatasetReferenceInput | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs/CrossDatasetReferenceInput/__tests__/CrossDatasetReferenceInput.test.tsx | /* eslint-disable camelcase */
import {act, waitForElementToBeRemoved, within} from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import React from 'react'
import {Observable, of} from 'rxjs'
import {SanityClient} from '@sanity/client'
import {renderCrossDatasetReferenceInput} from '../.... | 3,078 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs/CrossDatasetReferenceInput | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs/CrossDatasetReferenceInput/__tests__/mocks.ts | export const featureEnabledRequest = [
'thirdPartyLogin',
'scheduledPublishing',
'roleViewer',
'roleEditor',
'roleDeveloper',
'roleContributor',
'privateDataset',
'crossDatasetReferences',
'authSAML',
'advancedRolesManagement',
'advancedDatasetManagement',
'activityFeed',
]
export const feature... | 3,079 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs/CrossDatasetReferenceInput | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs/CrossDatasetReferenceInput/utils/AutocompleteHeightFix.tsx | import styled from 'styled-components'
export const AutocompleteHeightFix = styled.div`
// workaround for an issue that caused the autocomplete to not be the same height as the New button
// after removing, make sure they align perfectly
line-height: 0;
// also adds a margin at top/bottom to keep a stable hei... | 3,080 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs/CrossDatasetReferenceInput | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs/CrossDatasetReferenceInput/utils/useOnClickOutside.ts | // Modified version of https://usehooks.com/useOnClickOutside that can take multiple refs
import {RefObject, useEffect} from 'react'
export function useOnClickOutside(refs: RefObject<HTMLElement>[], handler: (event: Event) => void) {
useEffect(() => {
const listener = (event: Event) => {
const target = eve... | 3,081 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs/CrossDatasetReferenceInput | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs/CrossDatasetReferenceInput/utils/useProjectId.ts | import {useClient} from '../../../../hooks'
import {DEFAULT_STUDIO_CLIENT_OPTIONS} from '../../../../studioClient'
export function useProjectId(): string {
const client = useClient(DEFAULT_STUDIO_CLIENT_OPTIONS)
return client.config().projectId as string
}
| 3,082 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs/DateInputs/CommonDateTimeInput.tsx | /* eslint-disable no-nested-ternary */
import React, {useEffect} from 'react'
import {TextInput, useForwardedRef} from '@sanity/ui'
import {DateTimeInput} from './base/DateTimeInput'
import {ParseResult} from './types'
export interface CommonDateTimeInputProps {
id: string
deserialize: (value: string) => ParseRe... | 3,083 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs/DateInputs/DateInput.tsx | import React, {useCallback} from 'react'
import {format, parse} from '@sanity/util/legacyDateFormat'
import {set, unset} from '../../patch'
import {StringInputProps} from '../../types'
import {CommonDateTimeInput} from './CommonDateTimeInput'
interface ParsedOptions {
dateFormat: string
calendarTodayLabel: string
... | 3,084 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs/DateInputs/DateTimeInput.tsx | import {format, parse} from '@sanity/util/legacyDateFormat'
import {getMinutes, setMinutes, parseISO} from 'date-fns'
import React, {useCallback} from 'react'
import {set, unset} from '../../patch'
import {StringInputProps} from '../../types'
import {CommonDateTimeInput} from './CommonDateTimeInput'
import {ParseResult... | 3,085 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs/DateInputs/index.ts | export {DateTimeInput, type DateTimeInputProps} from './DateTimeInput'
export {DateInput, type DateInputProps} from './DateInput'
| 3,086 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs/DateInputs/types.ts | export type ParseResult = {isValid: boolean; date?: Date; error?: string} & (
| {isValid: true; date: Date}
| {isValid: false; error?: string}
)
| 3,087 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs/DateInputs/utils.ts | export function isValidDate(date: Date) {
return date instanceof Date && !isNaN(date.valueOf())
}
| 3,088 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs/DateInputs | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs/DateInputs/__tests__/CommonDateTimeInput.test.tsx | import {fireEvent} from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import {format, parse} from 'date-fns'
import React from 'react'
import {defineField} from '@sanity/types'
import {ParseResult} from '../types'
import {CommonDateTimeInput} from '../CommonDateTimeInput'
import {isValidD... | 3,089 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs/DateInputs | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs/DateInputs/__tests__/DateInput.test.tsx | import {defineField} from '@sanity/types'
import {fireEvent} from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import React from 'react'
import {renderStringInput} from '../../../../../../test/form'
import {DateInput} from '../DateInput'
// NOTE: for the tests to be deterministic we nee... | 3,090 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs/DateInputs | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs/DateInputs/__tests__/DateTimeInput.test.tsx | import {defineField} from '@sanity/types'
import {fireEvent} from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import React from 'react'
import {renderStringInput} from '../../../../../../test/form'
import {DateTimeInput} from '../DateTimeInput'
// NOTE: for the tests to be deterministi... | 3,091 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs/DateInputs/__tests__ | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs/DateInputs/__tests__/__snapshots__/DateInput.test.tsx.snap | // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`emits onChange on correct format if a valid value has been typed 1`] = `
Array [
Array [
Object {
"patchType": Symbol(sanity.patch),
"path": Array [],
"type": "set",
"value": "2021-03-28",
},
],
]
`;
| 3,092 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs/DateInputs/__tests__ | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs/DateInputs/__tests__/__snapshots__/DateTimeInput.test.tsx.snap | // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`emits onChange on correct format if a valid value has been typed 1`] = `
Array [
Array [
Object {
"patchType": Symbol(sanity.patch),
"path": Array [],
"type": "set",
"value": "2021-03-28T17:23:00.000Z",
},
],
]
`;
| 3,093 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs/DateInputs | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs/DateInputs/base/DatePicker.tsx | import React from 'react'
import {Calendar} from './calendar/Calendar'
export const DatePicker = React.forwardRef(function DatePicker(
props: Omit<React.ComponentProps<'div'>, 'onChange'> & {
value?: Date
onChange: (nextDate: Date) => void
selectTime?: boolean
timeStep?: number
},
ref: React.Forw... | 3,094 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs/DateInputs | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs/DateInputs/base/DateTimeInput.tsx | import React, {forwardRef, useCallback, useRef, useState} from 'react'
import FocusLock from 'react-focus-lock'
import {Box, Button, LayerProvider, Popover, useClickOutside, useForwardedRef} from '@sanity/ui'
import {CalendarIcon} from '@sanity/icons'
import {DatePicker} from './DatePicker'
import {LazyTextInput} from ... | 3,095 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs/DateInputs | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs/DateInputs/base/LazyTextInput.tsx | import React from 'react'
import {TextInput} from '@sanity/ui'
type TextInputProps = React.ComponentProps<typeof TextInput>
// todo: delete this when v0.34 of @sanity/ui is out
type Workaround = any
type Props = Workaround &
Omit<TextInputProps, 'onChange'> & {
onChange?: (
event: React.FocusEvent<HTMLIn... | 3,096 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs/DateInputs/base | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs/DateInputs/base/calendar/Calendar.tsx | import {Box, Button, Flex, Grid, Select, Text, useForwardedRef} from '@sanity/ui'
import {ChevronLeftIcon, ChevronRightIcon} from '@sanity/icons'
import {addDays, addMonths, setDate, setHours, setMinutes, setMonth, setYear} from 'date-fns'
import {range} from 'lodash'
import React, {forwardRef, useCallback, useEffect} ... | 3,097 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs/DateInputs/base | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs/DateInputs/base/calendar/CalendarDay.tsx | import {Card, Text} from '@sanity/ui'
import React, {useCallback} from 'react'
interface CalendarDayProps {
date: Date
focused?: boolean
onSelect: (date: Date) => void
isCurrentMonth?: boolean
isToday: boolean
selected?: boolean
}
export function CalendarDay(props: CalendarDayProps) {
const {date, focus... | 3,098 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs/DateInputs/base | petrpan-code/sanity-io/sanity/packages/sanity/src/core/form/inputs/DateInputs/base/calendar/CalendarMonth.tsx | import {Box, Grid, Text} from '@sanity/ui'
import {isSameDay, isSameMonth} from 'date-fns'
import React from 'react'
import {CalendarDay} from './CalendarDay'
import {WEEK_DAY_NAMES} from './constants'
import {getWeeksOfMonth} from './utils'
interface CalendarMonthProps {
date: Date
focused?: Date
selected?: Dat... | 3,099 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.