ics-ui-kit 0.1.0-alpha.48 → 0.1.0-alpha.49
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/{CheckboxField-DvsGq3kV.js → CheckboxField-BR2hWwTO.js} +2 -2
- package/dist/{CheckboxField-DvsGq3kV.js.map → CheckboxField-BR2hWwTO.js.map} +1 -1
- package/dist/{Command-BU9Ouar3.js → Command-C_iW2joV.js} +2 -2
- package/dist/{Command-BU9Ouar3.js.map → Command-C_iW2joV.js.map} +1 -1
- package/dist/{Field-CdocNMjg.js → Field-DpbrZvvg.js} +2 -2
- package/dist/{Field-CdocNMjg.js.map → Field-DpbrZvvg.js.map} +1 -1
- package/dist/{FieldLabel-DRwAhGMz.js → FieldLabel-saPDMPPr.js} +2 -2
- package/dist/{FieldLabel-DRwAhGMz.js.map → FieldLabel-saPDMPPr.js.map} +1 -1
- package/dist/{FormFooterTemplate-1MNxzQ7J.js → FormFooterTemplate-DV4pN3b-.js} +2 -2
- package/dist/{FormFooterTemplate-1MNxzQ7J.js.map → FormFooterTemplate-DV4pN3b-.js.map} +1 -1
- package/dist/{FormStack-DbtLshF8.js → FormStack-D-0fK-Zy.js} +3 -3
- package/dist/{FormStack-DbtLshF8.js.map → FormStack-D-0fK-Zy.js.map} +1 -1
- package/dist/{IconTooltip-CibXkFmt.js → IconTooltip-BbswlF6Q.js} +3 -3
- package/dist/IconTooltip-BbswlF6Q.js.map +1 -0
- package/dist/{MenuItemShortcut-CGbVYqRi.js → MenuItemShortcut-DK7VneTR.js} +2 -2
- package/dist/{MenuItemShortcut-CGbVYqRi.js.map → MenuItemShortcut-DK7VneTR.js.map} +1 -1
- package/dist/{Popover-CcZCvF57.js → Popover-DmwXZwYd.js} +16 -16
- package/dist/{Popover-CcZCvF57.js.map → Popover-DmwXZwYd.js.map} +1 -1
- package/dist/{SearchSelectTag-D1bFK1ux.js → SearchSelectTag-Ce-Q9JGR.js} +2 -2
- package/dist/{SearchSelectTag-D1bFK1ux.js.map → SearchSelectTag-Ce-Q9JGR.js.map} +1 -1
- package/dist/{Select-Bfrb-J8s.js → Select-CWbLja8r.js} +195 -195
- package/dist/{Select-Bfrb-J8s.js.map → Select-CWbLja8r.js.map} +1 -1
- package/dist/Shortcut-D8L15_ed.js +22 -0
- package/dist/Shortcut-D8L15_ed.js.map +1 -0
- package/dist/{Tag-DJuVSJh5.js → Tag-CofZF1d0.js} +6 -6
- package/dist/Tag-CofZF1d0.js.map +1 -0
- package/dist/{Toggle-CS29Nksd.js → Toggle-CCD2UHWr.js} +15 -13
- package/dist/Toggle-CCD2UHWr.js.map +1 -0
- package/dist/{Tooltip-Cm1-WEdA.js → Tooltip-BH_Jc6ub.js} +2 -2
- package/dist/{Tooltip-Cm1-WEdA.js.map → Tooltip-BH_Jc6ub.js.map} +1 -1
- package/dist/blocks/auth/otp-form.js +1 -1
- package/dist/components/avatar/Avatar.d.ts +1 -1
- package/dist/components/avatar/avatar-indicator/AvatarIndicator.d.ts +3 -1
- package/dist/components/avatar/avatar-label/AvatarLabel.d.ts +1 -1
- package/dist/components/avatar.js +110 -93
- package/dist/components/avatar.js.map +1 -1
- package/dist/components/checkbox.js +1 -1
- package/dist/components/command.js +1 -1
- package/dist/components/dialog.js +1 -1
- package/dist/components/drawer.js +1 -1
- package/dist/components/dropdown.js +1 -1
- package/dist/components/field.js +1 -1
- package/dist/components/form.js +3 -3
- package/dist/components/icon-tooltip.js +1 -1
- package/dist/components/label.js +1 -1
- package/dist/components/menu-item.js +1 -1
- package/dist/components/overflow-tooltip.js +1 -1
- package/dist/components/popover.js +1 -1
- package/dist/components/scheduler.js +1 -1
- package/dist/components/search-select.js +4 -4
- package/dist/components/select.js +1 -1
- package/dist/components/shortcut.js +1 -1
- package/dist/components/sidebar.js +67 -67
- package/dist/components/sidebar.js.map +1 -1
- package/dist/components/switch.js +1 -1
- package/dist/components/tag-input.js +2 -2
- package/dist/components/tag.js +1 -1
- package/dist/components/toggle/Toggle.d.ts +8 -2
- package/dist/components/toggle-group.js +1 -1
- package/dist/components/toggle.js +1 -1
- package/dist/components/tooltip.js +1 -1
- package/dist/styles-scoped.css +38 -21
- package/dist/styles.css +38 -21
- package/package.json +1 -1
- package/dist/IconTooltip-CibXkFmt.js.map +0 -1
- package/dist/Shortcut-Cm4nUx2C.js +0 -22
- package/dist/Shortcut-Cm4nUx2C.js.map +0 -1
- package/dist/Tag-DJuVSJh5.js.map +0 -1
- package/dist/Toggle-CS29Nksd.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormStack-DbtLshF8.js","sources":["../src/components/form/Form.tsx","../src/components/form/components/form-field/FormField.tsx","../src/components/form/components/form-stack/FormStack.tsx"],"sourcesContent":["import * as React from \"react\";\nimport * as LabelPrimitive from \"@radix-ui/react-label\";\nimport { Slot } from \"@radix-ui/react-slot\";\nimport {\n\tController,\n\tFormProvider,\n\tuseFormContext,\n\ttype ControllerProps,\n\ttype FieldPath,\n\ttype FieldValues\n} from \"react-hook-form\";\nimport { tv } from \"tailwind-variants\";\nimport { FieldLabel } from \"../label/field-label/FieldLabel\";\n\nconst formStyle = tv({\n\tbase: \"rounded-md border border-secondary-border bg-secondary-bg\"\n});\n\n/**\n * Основной контейнер формы\n */\nconst Form = <T extends FieldValues>({\n\tclassName,\n\tasChild,\n\t...props\n}: React.ComponentProps<typeof FormProvider<T>> & {\n\t/** Дополнительные классы */\n\tclassName?: string;\n\t/** Использовать ли дочерний элемент как корневой */\n\tasChild?: boolean;\n}) => {\n\tconst Comp = asChild ? Slot : \"div\";\n\treturn (\n\t\t<Comp className={formStyle({ className })}>\n\t\t\t<FormProvider {...props} />\n\t\t</Comp>\n\t);\n};\n\ntype FormFieldContextValue<\n\tTFieldValues extends FieldValues = FieldValues,\n\tTName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\n> = {\n\tname: TName;\n};\n\nconst FormFieldContext = React.createContext<FormFieldContextValue>({} as FormFieldContextValue);\n\n/**\n * Поле формы с валидацией\n */\n\nconst FormField = <\n\tTFieldValues extends FieldValues = FieldValues,\n\tTName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\n>({\n\t...props\n}: ControllerProps<TFieldValues, TName>) => {\n\treturn (\n\t\t<FormFieldContext.Provider value={{ name: props.name }}>\n\t\t\t<Controller {...props} />\n\t\t</FormFieldContext.Provider>\n\t);\n};\n\nconst useFormField = () => {\n\tconst fieldContext = React.useContext(FormFieldContext);\n\tconst itemContext = React.useContext(FormItemContext);\n\tconst { getFieldState, formState } = useFormContext();\n\n\tconst fieldState = getFieldState(fieldContext.name, formState);\n\n\tif (!fieldContext) {\n\t\tthrow new Error(\"useFormField should be used within <FormField>\");\n\t}\n\n\tconst { id } = itemContext;\n\n\treturn {\n\t\tid,\n\t\tname: fieldContext.name,\n\t\tformItemId: `${id}-form-item`,\n\t\tformDescriptionId: `${id}-form-item-description`,\n\t\tformMessageId: `${id}-form-item-message`,\n\t\t...fieldState\n\t};\n};\n\ntype FormItemContextValue = {\n\tid: string;\n};\n\nconst FormItemContext = React.createContext<FormItemContextValue>({} as FormItemContextValue);\n\nconst formItemStyle = tv({\n\tbase: \"space-y-2\"\n});\n\n/**\n * Контейнер для элементов формы\n */\nconst FormItem = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(\n\t({ className, ...props }, ref) => {\n\t\tconst id = React.useId();\n\n\t\treturn (\n\t\t\t<FormItemContext.Provider value={{ id }}>\n\t\t\t\t<div ref={ref} className={formItemStyle({ className })} {...props} />\n\t\t\t</FormItemContext.Provider>\n\t\t);\n\t}\n);\nFormItem.displayName = \"FormItem\";\n\ninterface FormLabelProps extends React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> {\n\t/** Обязательное ли поле */\n\trequired?: boolean;\n}\n\n/**\n * Лейбл для поля формы\n */\nconst FormLabel = React.forwardRef<React.ElementRef<typeof LabelPrimitive.Root>, FormLabelProps>(\n\t({ className, required, ...props }, ref) => {\n\t\tconst { formItemId } = useFormField();\n\n\t\treturn <FieldLabel required={required} ref={ref} className={className} htmlFor={formItemId} {...props} />;\n\t}\n);\nFormLabel.displayName = \"FormLabel\";\n\n/**\n * Контрол для поля формы\n */\nconst FormControl = React.forwardRef<React.ElementRef<typeof Slot>, React.ComponentPropsWithoutRef<typeof Slot>>(\n\t({ ...props }, ref) => {\n\t\tconst { error, formItemId, formDescriptionId, formMessageId } = useFormField();\n\n\t\treturn (\n\t\t\t<Slot\n\t\t\t\tref={ref}\n\t\t\t\tid={formItemId}\n\t\t\t\taria-describedby={!error ? `${formDescriptionId}` : `${formDescriptionId} ${formMessageId}`}\n\t\t\t\taria-invalid={!!error}\n\t\t\t\t{...props}\n\t\t\t/>\n\t\t);\n\t}\n);\nFormControl.displayName = \"FormControl\";\n\nconst formMessageStyle = tv({\n\tbase: \"text-[0.8rem] font-medium text-destructive\"\n});\n\n/**\n * Сообщение об ошибке\n */\nconst FormMessage = React.forwardRef<HTMLParagraphElement, React.HTMLAttributes<HTMLParagraphElement>>(\n\t({ className, children, ...props }, ref) => {\n\t\tconst { error, formMessageId } = useFormField();\n\t\tconst body = error ? String(error?.message ?? \"\") : children;\n\n\t\tif (!body) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn (\n\t\t\t<p ref={ref} id={formMessageId} className={formMessageStyle({ className })} {...props}>\n\t\t\t\t{body}\n\t\t\t</p>\n\t\t);\n\t}\n);\nFormMessage.displayName = \"FormMessage\";\n\nexport { useFormField, Form, FormItem, FormLabel, FormControl, FormMessage, FormField as FormFieldControl };\n","import * as React from \"react\";\nimport {\n\tuseFormContext,\n\ttype FieldPath,\n\ttype FieldValues,\n\ttype ControllerRenderProps,\n\ttype UseFormStateReturn,\n\ttype ControllerFieldState,\n\tPath\n} from \"react-hook-form\";\nimport { FormFieldControl, FormItem, FormControl } from \"../../Form\";\nimport { Field, FieldLayout } from \"@/components/field/Field\";\nimport { tv } from \"tailwind-variants\";\n\nconst formFieldStyles = tv({\n\tslots: {\n\t\tlabel: \"w-44\"\n\t}\n});\n\nexport type FormFieldControlRenderer<TFieldValues extends FieldValues = FieldValues> = (props: {\n\tfield: ControllerRenderProps<TFieldValues, Path<TFieldValues>>;\n\tfieldState: ControllerFieldState;\n\tformState: UseFormStateReturn<TFieldValues>;\n\treadonly?: boolean;\n}) => React.ReactNode;\n\nexport interface FormFieldProps<\n\tTFieldValues extends FieldValues = FieldValues,\n\tTName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\n> {\n\t/** Имя поля формы */\n\tname: TName;\n\t/** Заголовок поля (лейбл) */\n\ttitle: string;\n\t/** Описание поля */\n\tdescription?: string;\n\t/** Функция рендеринга контрола */\n\tcontrol: FormFieldControlRenderer<TFieldValues>;\n\t/** Является ли поле обязательным */\n\trequired?: boolean;\n\t/** Дополнительные классы */\n\tclassName?: string;\n\t/** Классы для лейбла */\n\tlabelClassName?: string;\n\t/** Поле только для чтения */\n\treadonly?: boolean;\n\t/** Вариант расположения элементов поля */\n\tlayout?: FieldLayout;\n}\n\n/**\n * Компонент FormField объединяет несколько компонентов формы в один блок\n * для упрощения создания консистентных форм.\n *\n * ### Варианты раскладки (layout):\n *\n * - **responsive** (по умолчанию): адаптивная раскладка с mobile-first подходом.\n * На мобильных устройствах - вертикальный лейаут, на десктопе (от lg breakpoint) - горизонтальный.\n *\n * - **horizontal**: принудительно горизонтальная раскладка на всех экранах.\n * Лейбл располагается слева от поля ввода.\n *\n * - **vertical**: принудительно вертикальная раскладка на всех экранах.\n * Лейбл располагается над полем ввода.\n *\n * Компонент обеспечивает согласованное расположение элементов формы,\n * включая лейбл, поле ввода, подсказку и сообщение об ошибке.\n *\n * @example\n * <FormField\n * name=\"username\"\n * title=\"Имя пользователя\"\n * description=\"Ваше публичное имя пользователя\"\n * required\n * control={({ field }) => (\n * <TextInput\n * placeholder=\"Введите имя пользователя\"\n * startIcon={<Icon icon={User} />}\n * {...field}\n * />\n * )}\n * />\n */\n\nexport function FormField<\n\tTFieldValues extends FieldValues = FieldValues,\n\tTName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\n>({\n\tname,\n\ttitle,\n\tdescription,\n\tcontrol,\n\trequired,\n\tclassName,\n\tlabelClassName,\n\treadonly,\n\tlayout = \"responsive\"\n}: FormFieldProps<TFieldValues, TName>) {\n\tconst form = useFormContext<TFieldValues>();\n\tconst styles = formFieldStyles();\n\n\treturn (\n\t\t<FormFieldControl\n\t\t\tcontrol={form.control}\n\t\t\tname={name}\n\t\t\trender={({ field, fieldState, formState }) => {\n\t\t\t\treturn (\n\t\t\t\t\t<FormItem>\n\t\t\t\t\t\t<Field\n\t\t\t\t\t\t\ttitle={title}\n\t\t\t\t\t\t\tdescription={description}\n\t\t\t\t\t\t\trequired={required}\n\t\t\t\t\t\t\terror={fieldState.error?.message}\n\t\t\t\t\t\t\tlabelClassName={styles.label({ className: labelClassName })}\n\t\t\t\t\t\t\tclassName={className}\n\t\t\t\t\t\t\treadonly={readonly}\n\t\t\t\t\t\t\tlayout={layout}\n\t\t\t\t\t\t\tcontrol={({ id, readonly }) => (\n\t\t\t\t\t\t\t\t<FormControl id={id}>{control({ field, fieldState, formState, readonly })}</FormControl>\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</FormItem>\n\t\t\t\t);\n\t\t\t}}\n\t\t/>\n\t);\n}\n","import React from \"react\";\nimport { tv } from \"tailwind-variants\";\n\nconst formStackStyles = tv({\n\tbase: \"space-y-5 lg:space-y-4\"\n});\n\n/** Оболочка для группы полей формы с внутренними отступами */\nexport const FormStack = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(\n\t({ className, children, ...props }, ref) => {\n\t\treturn (\n\t\t\t<div ref={ref} className={formStackStyles({ className })} {...props}>\n\t\t\t\t{children}\n\t\t\t</div>\n\t\t);\n\t}\n);\n\nFormStack.displayName = \"FormStack\";\n"],"names":["formStyle","tv","Form","className","asChild","props","jsx","Slot","FormProvider","FormFieldContext","React","FormField","Controller","useFormField","fieldContext","itemContext","FormItemContext","getFieldState","formState","useFormContext","fieldState","id","formItemStyle","FormItem","ref","FormLabel","required","formItemId","FieldLabel","FormControl","error","formDescriptionId","formMessageId","formMessageStyle","FormMessage","children","body","formFieldStyles","name","title","description","control","labelClassName","readonly","layout","form","styles","FormFieldControl","field","Field","formStackStyles","FormStack"],"mappings":";;;;;;;;AAcA,MAAMA,IAAYC,EAAG;AAAA,EACpB,MAAM;AACP,CAAC,GAKKC,IAAO,CAAwB;AAAA,EACpC,WAAAC;AAAA,EACA,SAAAC;AAAA,EACA,GAAGC;AACJ,MAQG,gBAAAC,EAFWF,IAAUG,IAAO,OAE5B,EAAK,WAAWP,EAAU,EAAE,WAAAG,EAAA,CAAW,GACvC,UAAC,gBAAAG,EAAAE,GAAA,EAAc,GAAGH,EAAA,CAAO,EAC1B,CAAA,GAWII,IAAmBC,EAAM,cAAqC,EAA2B,GAMzFC,IAAY,CAGhB;AAAA,EACD,GAAGN;AACJ,MAEG,gBAAAC,EAAAG,EAAiB,UAAjB,EAA0B,OAAO,EAAE,MAAMJ,EAAM,KAAA,GAC/C,UAAA,gBAAAC,EAACM,GAAY,EAAA,GAAGP,EAAO,CAAA,GACxB,GAIIQ,IAAe,MAAM;AACpB,QAAAC,IAAeJ,EAAM,WAAWD,CAAgB,GAChDM,IAAcL,EAAM,WAAWM,CAAe,GAC9C,EAAE,eAAAC,GAAe,WAAAC,EAAU,IAAIC,EAAe,GAE9CC,IAAaH,EAAcH,EAAa,MAAMI,CAAS;AAE7D,MAAI,CAACJ;AACE,UAAA,IAAI,MAAM,gDAAgD;AAG3D,QAAA,EAAE,IAAAO,MAAON;AAER,SAAA;AAAA,IACN,IAAAM;AAAA,IACA,MAAMP,EAAa;AAAA,IACnB,YAAY,GAAGO,CAAE;AAAA,IACjB,mBAAmB,GAAGA,CAAE;AAAA,IACxB,eAAe,GAAGA,CAAE;AAAA,IACpB,GAAGD;AAAA,EACJ;AACD,GAMMJ,IAAkBN,EAAM,cAA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oB,EAAQ,EAAE,OAAAO,GAAO,YAAA5B,GAAY,WAAAF,GAAW,UAAAyB,EAAAA,CAAU,EAAE,CAAA;AAAA,QAAA;AAAA,MAAA,GAG7E;AAAA,IAEF;AAAA,EACD;AAEF;AC5HA,MAAMO,IAAkBjD,EAAG;AAAA,EAC1B,MAAM;AACP,CAAC,GAGYkD,IAAYzC,EAAM;AAAA,EAC9B,CAAC,EAAE,WAAAP,GAAW,UAAAgC,GAAU,GAAG9B,EAAA,GAASmB,MAElC,gBAAAlB,EAAC,OAAI,EAAA,KAAAkB,GAAU,WAAW0B,EAAgB,EAAE,WAAA/C,GAAW,GAAI,GAAGE,GAC5D,UAAA8B,EACF,CAAA;AAGH;AAEAgB,EAAU,cAAc;"}
|
|
1
|
+
{"version":3,"file":"FormStack-D-0fK-Zy.js","sources":["../src/components/form/Form.tsx","../src/components/form/components/form-field/FormField.tsx","../src/components/form/components/form-stack/FormStack.tsx"],"sourcesContent":["import * as React from \"react\";\nimport * as LabelPrimitive from \"@radix-ui/react-label\";\nimport { Slot } from \"@radix-ui/react-slot\";\nimport {\n\tController,\n\tFormProvider,\n\tuseFormContext,\n\ttype ControllerProps,\n\ttype FieldPath,\n\ttype FieldValues\n} from \"react-hook-form\";\nimport { tv } from \"tailwind-variants\";\nimport { FieldLabel } from \"../label/field-label/FieldLabel\";\n\nconst formStyle = tv({\n\tbase: \"rounded-md border border-secondary-border bg-secondary-bg\"\n});\n\n/**\n * Основной контейнер формы\n */\nconst Form = <T extends FieldValues>({\n\tclassName,\n\tasChild,\n\t...props\n}: React.ComponentProps<typeof FormProvider<T>> & {\n\t/** Дополнительные классы */\n\tclassName?: string;\n\t/** Использовать ли дочерний элемент как корневой */\n\tasChild?: boolean;\n}) => {\n\tconst Comp = asChild ? Slot : \"div\";\n\treturn (\n\t\t<Comp className={formStyle({ className })}>\n\t\t\t<FormProvider {...props} />\n\t\t</Comp>\n\t);\n};\n\ntype FormFieldContextValue<\n\tTFieldValues extends FieldValues = FieldValues,\n\tTName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\n> = {\n\tname: TName;\n};\n\nconst FormFieldContext = React.createContext<FormFieldContextValue>({} as FormFieldContextValue);\n\n/**\n * Поле формы с валидацией\n */\n\nconst FormField = <\n\tTFieldValues extends FieldValues = FieldValues,\n\tTName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\n>({\n\t...props\n}: ControllerProps<TFieldValues, TName>) => {\n\treturn (\n\t\t<FormFieldContext.Provider value={{ name: props.name }}>\n\t\t\t<Controller {...props} />\n\t\t</FormFieldContext.Provider>\n\t);\n};\n\nconst useFormField = () => {\n\tconst fieldContext = React.useContext(FormFieldContext);\n\tconst itemContext = React.useContext(FormItemContext);\n\tconst { getFieldState, formState } = useFormContext();\n\n\tconst fieldState = getFieldState(fieldContext.name, formState);\n\n\tif (!fieldContext) {\n\t\tthrow new Error(\"useFormField should be used within <FormField>\");\n\t}\n\n\tconst { id } = itemContext;\n\n\treturn {\n\t\tid,\n\t\tname: fieldContext.name,\n\t\tformItemId: `${id}-form-item`,\n\t\tformDescriptionId: `${id}-form-item-description`,\n\t\tformMessageId: `${id}-form-item-message`,\n\t\t...fieldState\n\t};\n};\n\ntype FormItemContextValue = {\n\tid: string;\n};\n\nconst FormItemContext = React.createContext<FormItemContextValue>({} as FormItemContextValue);\n\nconst formItemStyle = tv({\n\tbase: \"space-y-2\"\n});\n\n/**\n * Контейнер для элементов формы\n */\nconst FormItem = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(\n\t({ className, ...props }, ref) => {\n\t\tconst id = React.useId();\n\n\t\treturn (\n\t\t\t<FormItemContext.Provider value={{ id }}>\n\t\t\t\t<div ref={ref} className={formItemStyle({ className })} {...props} />\n\t\t\t</FormItemContext.Provider>\n\t\t);\n\t}\n);\nFormItem.displayName = \"FormItem\";\n\ninterface FormLabelProps extends React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> {\n\t/** Обязательное ли поле */\n\trequired?: boolean;\n}\n\n/**\n * Лейбл для поля формы\n */\nconst FormLabel = React.forwardRef<React.ElementRef<typeof LabelPrimitive.Root>, FormLabelProps>(\n\t({ className, required, ...props }, ref) => {\n\t\tconst { formItemId } = useFormField();\n\n\t\treturn <FieldLabel required={required} ref={ref} className={className} htmlFor={formItemId} {...props} />;\n\t}\n);\nFormLabel.displayName = \"FormLabel\";\n\n/**\n * Контрол для поля формы\n */\nconst FormControl = React.forwardRef<React.ElementRef<typeof Slot>, React.ComponentPropsWithoutRef<typeof Slot>>(\n\t({ ...props }, ref) => {\n\t\tconst { error, formItemId, formDescriptionId, formMessageId } = useFormField();\n\n\t\treturn (\n\t\t\t<Slot\n\t\t\t\tref={ref}\n\t\t\t\tid={formItemId}\n\t\t\t\taria-describedby={!error ? `${formDescriptionId}` : `${formDescriptionId} ${formMessageId}`}\n\t\t\t\taria-invalid={!!error}\n\t\t\t\t{...props}\n\t\t\t/>\n\t\t);\n\t}\n);\nFormControl.displayName = \"FormControl\";\n\nconst formMessageStyle = tv({\n\tbase: \"text-[0.8rem] font-medium text-destructive\"\n});\n\n/**\n * Сообщение об ошибке\n */\nconst FormMessage = React.forwardRef<HTMLParagraphElement, React.HTMLAttributes<HTMLParagraphElement>>(\n\t({ className, children, ...props }, ref) => {\n\t\tconst { error, formMessageId } = useFormField();\n\t\tconst body = error ? String(error?.message ?? \"\") : children;\n\n\t\tif (!body) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn (\n\t\t\t<p ref={ref} id={formMessageId} className={formMessageStyle({ className })} {...props}>\n\t\t\t\t{body}\n\t\t\t</p>\n\t\t);\n\t}\n);\nFormMessage.displayName = \"FormMessage\";\n\nexport { useFormField, Form, FormItem, FormLabel, FormControl, FormMessage, FormField as FormFieldControl };\n","import * as React from \"react\";\nimport {\n\tuseFormContext,\n\ttype FieldPath,\n\ttype FieldValues,\n\ttype ControllerRenderProps,\n\ttype UseFormStateReturn,\n\ttype ControllerFieldState,\n\tPath\n} from \"react-hook-form\";\nimport { FormFieldControl, FormItem, FormControl } from \"../../Form\";\nimport { Field, FieldLayout } from \"@/components/field/Field\";\nimport { tv } from \"tailwind-variants\";\n\nconst formFieldStyles = tv({\n\tslots: {\n\t\tlabel: \"w-44\"\n\t}\n});\n\nexport type FormFieldControlRenderer<TFieldValues extends FieldValues = FieldValues> = (props: {\n\tfield: ControllerRenderProps<TFieldValues, Path<TFieldValues>>;\n\tfieldState: ControllerFieldState;\n\tformState: UseFormStateReturn<TFieldValues>;\n\treadonly?: boolean;\n}) => React.ReactNode;\n\nexport interface FormFieldProps<\n\tTFieldValues extends FieldValues = FieldValues,\n\tTName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\n> {\n\t/** Имя поля формы */\n\tname: TName;\n\t/** Заголовок поля (лейбл) */\n\ttitle: string;\n\t/** Описание поля */\n\tdescription?: string;\n\t/** Функция рендеринга контрола */\n\tcontrol: FormFieldControlRenderer<TFieldValues>;\n\t/** Является ли поле обязательным */\n\trequired?: boolean;\n\t/** Дополнительные классы */\n\tclassName?: string;\n\t/** Классы для лейбла */\n\tlabelClassName?: string;\n\t/** Поле только для чтения */\n\treadonly?: boolean;\n\t/** Вариант расположения элементов поля */\n\tlayout?: FieldLayout;\n}\n\n/**\n * Компонент FormField объединяет несколько компонентов формы в один блок\n * для упрощения создания консистентных форм.\n *\n * ### Варианты раскладки (layout):\n *\n * - **responsive** (по умолчанию): адаптивная раскладка с mobile-first подходом.\n * На мобильных устройствах - вертикальный лейаут, на десктопе (от lg breakpoint) - горизонтальный.\n *\n * - **horizontal**: принудительно горизонтальная раскладка на всех экранах.\n * Лейбл располагается слева от поля ввода.\n *\n * - **vertical**: принудительно вертикальная раскладка на всех экранах.\n * Лейбл располагается над полем ввода.\n *\n * Компонент обеспечивает согласованное расположение элементов формы,\n * включая лейбл, поле ввода, подсказку и сообщение об ошибке.\n *\n * @example\n * <FormField\n * name=\"username\"\n * title=\"Имя пользователя\"\n * description=\"Ваше публичное имя пользователя\"\n * required\n * control={({ field }) => (\n * <TextInput\n * placeholder=\"Введите имя пользователя\"\n * startIcon={<Icon icon={User} />}\n * {...field}\n * />\n * )}\n * />\n */\n\nexport function FormField<\n\tTFieldValues extends FieldValues = FieldValues,\n\tTName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\n>({\n\tname,\n\ttitle,\n\tdescription,\n\tcontrol,\n\trequired,\n\tclassName,\n\tlabelClassName,\n\treadonly,\n\tlayout = \"responsive\"\n}: FormFieldProps<TFieldValues, TName>) {\n\tconst form = useFormContext<TFieldValues>();\n\tconst styles = formFieldStyles();\n\n\treturn (\n\t\t<FormFieldControl\n\t\t\tcontrol={form.control}\n\t\t\tname={name}\n\t\t\trender={({ field, fieldState, formState }) => {\n\t\t\t\treturn (\n\t\t\t\t\t<FormItem>\n\t\t\t\t\t\t<Field\n\t\t\t\t\t\t\ttitle={title}\n\t\t\t\t\t\t\tdescription={description}\n\t\t\t\t\t\t\trequired={required}\n\t\t\t\t\t\t\terror={fieldState.error?.message}\n\t\t\t\t\t\t\tlabelClassName={styles.label({ className: labelClassName })}\n\t\t\t\t\t\t\tclassName={className}\n\t\t\t\t\t\t\treadonly={readonly}\n\t\t\t\t\t\t\tlayout={layout}\n\t\t\t\t\t\t\tcontrol={({ id, readonly }) => (\n\t\t\t\t\t\t\t\t<FormControl id={id}>{control({ field, fieldState, formState, readonly })}</FormControl>\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</FormItem>\n\t\t\t\t);\n\t\t\t}}\n\t\t/>\n\t);\n}\n","import React from \"react\";\nimport { tv } from \"tailwind-variants\";\n\nconst formStackStyles = tv({\n\tbase: \"space-y-5 lg:space-y-4\"\n});\n\n/** Оболочка для группы полей формы с внутренними отступами */\nexport const FormStack = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(\n\t({ className, children, ...props }, ref) => {\n\t\treturn (\n\t\t\t<div ref={ref} className={formStackStyles({ className })} {...props}>\n\t\t\t\t{children}\n\t\t\t</div>\n\t\t);\n\t}\n);\n\nFormStack.displayName = \"FormStack\";\n"],"names":["formStyle","tv","Form","className","asChild","props","jsx","Slot","FormProvider","FormFieldContext","React","FormField","Controller","useFormField","fieldContext","itemContext","FormItemContext","getFieldState","formState","useFormContext","fieldState","id","formItemStyle","FormItem","ref","FormLabel","required","formItemId","FieldLabel","FormControl","error","formDescriptionId","formMessageId","formMessageStyle","FormMessage","children","body","formFieldStyles","name","title","description","control","labelClassName","readonly","layout","form","styles","FormFieldControl","field","Field","formStackStyles","FormStack"],"mappings":";;;;;;;;AAcA,MAAMA,IAAYC,EAAG;AAAA,EACpB,MAAM;AACP,CAAC,GAKKC,IAAO,CAAwB;AAAA,EACpC,WAAAC;AAAA,EACA,SAAAC;AAAA,EACA,GAAGC;AACJ,MAQG,gBAAAC,EAFWF,IAAUG,IAAO,OAE5B,EAAK,WAAWP,EAAU,EAAE,WAAAG,EAAA,CAAW,GACvC,UAAC,gBAAAG,EAAAE,GAAA,EAAc,GAAGH,EAAA,CAAO,EAC1B,CAAA,GAWII,IAAmBC,EAAM,cAAqC,EAA2B,GAMzFC,IAAY,CAGhB;AAAA,EACD,GAAGN;AACJ,MAEG,gBAAAC,EAAAG,EAAiB,UAAjB,EAA0B,OAAO,EAAE,MAAMJ,EAAM,KAAA,GAC/C,UAAA,gBAAAC,EAACM,GAAY,EAAA,GAAGP,EAAO,CAAA,GACxB,GAIIQ,IAAe,MAAM;AACpB,QAAAC,IAAeJ,EAAM,WAAWD,CAAgB,GAChDM,IAAcL,EAAM,WAAWM,CAAe,GAC9C,EAAE,eAAAC,GAAe,WAAAC,EAAU,IAAIC,EAAe,GAE9CC,IAAaH,EAAcH,EAAa,MAAMI,CAAS;AAE7D,MAAI,CAACJ;AACE,UAAA,IAAI,MAAM,gDAAgD;AAG3D,QAAA,EAAE,IAAAO,MAAON;AAER,SAAA;AAAA,IACN,IAAAM;AAAA,IACA,MAAMP,EAAa;AAAA,IACnB,YAAY,GAAGO,CAAE;AAA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C;AAAA,UACA,QAAAC;AAAA,UACA,SAAS,CAAC,EAAE,IAAAvB,GAAI,UAAAsB,QACd,gBAAArC,EAAAuB,GAAA,EAAY,IAAAR,GAAS,UAAAoB,EAAQ,EAAE,OAAAO,GAAO,YAAA5B,GAAY,WAAAF,GAAW,UAAAyB,EAAAA,CAAU,EAAE,CAAA;AAAA,QAAA;AAAA,MAAA,GAG7E;AAAA,IAEF;AAAA,EACD;AAEF;AC5HA,MAAMO,IAAkBjD,EAAG;AAAA,EAC1B,MAAM;AACP,CAAC,GAGYkD,IAAYzC,EAAM;AAAA,EAC9B,CAAC,EAAE,WAAAP,GAAW,UAAAgC,GAAU,GAAG9B,EAAA,GAASmB,MAElC,gBAAAlB,EAAC,OAAI,EAAA,KAAAkB,GAAU,WAAW0B,EAAgB,EAAE,WAAA/C,GAAW,GAAI,GAAGE,GAC5D,UAAA8B,EACF,CAAA;AAGH;AAEAgB,EAAU,cAAc;"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { jsx as o, jsxs as a } from "react/jsx-runtime";
|
|
2
2
|
import { I as l } from "./Icon-DH3ev9GK.js";
|
|
3
|
-
import { a as c, T as n, b as m, c as p } from "./Tooltip-
|
|
3
|
+
import { a as c, T as n, b as m, c as p } from "./Tooltip-BH_Jc6ub.js";
|
|
4
4
|
const I = ({ content: r, icon: s, iconClassName: i, iconSize: t = "sm", contentClassName: e }) => /* @__PURE__ */ o(c, { children: /* @__PURE__ */ a(n, { children: [
|
|
5
|
-
/* @__PURE__ */ o(m, {
|
|
5
|
+
/* @__PURE__ */ o(m, { children: /* @__PURE__ */ o(l, { size: t, className: i, icon: s }) }),
|
|
6
6
|
/* @__PURE__ */ o(p, { className: e, children: r })
|
|
7
7
|
] }) });
|
|
8
8
|
export {
|
|
9
9
|
I
|
|
10
10
|
};
|
|
11
|
-
//# sourceMappingURL=IconTooltip-
|
|
11
|
+
//# sourceMappingURL=IconTooltip-BbswlF6Q.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IconTooltip-BbswlF6Q.js","sources":["../src/components/icon-tooltip/IconTooltip.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { Icon } from \"@/components/icon/Icon\";\nimport { LucideIcon } from \"lucide-react\";\nimport { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from \"../tooltip/Tooltip\";\n\nexport interface IconTooltipProps {\n\tcontent: React.ReactNode;\n\ticon: LucideIcon;\n\ticonSize?: \"sm\" | \"md\" | \"lg\";\n\ticonClassName?: string;\n\tcontentClassName?: string;\n}\n\nexport const IconTooltip = ({ content, icon, iconClassName, iconSize = \"sm\", contentClassName }: IconTooltipProps) => {\n\treturn (\n\t\t<TooltipProvider>\n\t\t\t<Tooltip>\n\t\t\t\t<TooltipTrigger>\n\t\t\t\t\t<Icon size={iconSize} className={iconClassName} icon={icon} />\n\t\t\t\t</TooltipTrigger>\n\t\t\t\t<TooltipContent className={contentClassName}>{content}</TooltipContent>\n\t\t\t</Tooltip>\n\t\t</TooltipProvider>\n\t);\n};\n"],"names":["IconTooltip","content","icon","iconClassName","iconSize","contentClassName","jsx","TooltipProvider","jsxs","Tooltip","TooltipTrigger","Icon","TooltipContent"],"mappings":";;;AAaa,MAAAA,IAAc,CAAC,EAAE,SAAAC,GAAS,MAAAC,GAAM,eAAAC,GAAe,UAAAC,IAAW,MAAM,kBAAAC,QAE3E,gBAAAC,EAACC,GACA,EAAA,UAAA,gBAAAC,EAACC,GACA,EAAA,UAAA;AAAA,EAAC,gBAAAH,EAAAI,GAAA,EACA,4BAACC,GAAK,EAAA,MAAMP,GAAU,WAAWD,GAAe,MAAAD,GAAY,EAC7D,CAAA;AAAA,EACC,gBAAAI,EAAAM,GAAA,EAAe,WAAWP,GAAmB,UAAQJ,EAAA,CAAA;AAAA,EAAA,CACvD,EACD,CAAA;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as m } from "react/jsx-runtime";
|
|
2
|
-
import { S as s } from "./Shortcut-
|
|
2
|
+
import { S as s } from "./Shortcut-D8L15_ed.js";
|
|
3
3
|
import { u as a } from "./ComponentVariantProvider-B0SFUaXB.js";
|
|
4
4
|
import { T as n } from "./index-BVqs-uqP.js";
|
|
5
5
|
const u = n({
|
|
@@ -18,4 +18,4 @@ export {
|
|
|
18
18
|
i as M,
|
|
19
19
|
u as m
|
|
20
20
|
};
|
|
21
|
-
//# sourceMappingURL=MenuItemShortcut-
|
|
21
|
+
//# sourceMappingURL=MenuItemShortcut-DK7VneTR.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MenuItemShortcut-
|
|
1
|
+
{"version":3,"file":"MenuItemShortcut-DK7VneTR.js","sources":["../src/components/menu-item/components/menu-item-shortcut/MenuItemShortcut.tsx"],"sourcesContent":["import { Shortcut } from \"@/components/shortcut\";\nimport { useComponentVariant } from \"@/providers/component-variant-context\";\nimport React from \"react\";\nimport { tv } from \"tailwind-variants\";\n\nexport const menuItemShortcutStyles = tv({\n\tbase: \"text-muted-foreground\",\n\tvariants: {\n\t\ttheme: {\n\t\t\tinverse: \"text-inverse-muted\"\n\t\t}\n\t}\n});\n\ntype MenuItemTextProps = React.HTMLAttributes<HTMLSpanElement>;\n\nexport const MenuItemShortcut = ({ className, children, ...props }: MenuItemTextProps) => {\n\tconst { variant: theme } = useComponentVariant();\n\n\treturn (\n\t\t<Shortcut variant=\"ghost\" className={menuItemShortcutStyles({ className, theme })} {...props}>\n\t\t\t{children}\n\t\t</Shortcut>\n\t);\n};\n\nMenuItemShortcut.displayName = \"MenuItemShortcut\";\n"],"names":["menuItemShortcutStyles","tv","MenuItemShortcut","className","children","props","theme","useComponentVariant","jsx","Shortcut"],"mappings":";;;;AAKO,MAAMA,IAAyBC,EAAG;AAAA,EACxC,MAAM;AAAA,EACN,UAAU;AAAA,IACT,OAAO;AAAA,MACN,SAAS;AAAA,IAAA;AAAA,EACV;AAEF,CAAC,GAIYC,IAAmB,CAAC,EAAE,WAAAC,GAAW,UAAAC,GAAU,GAAGC,QAA+B;AACzF,QAAM,EAAE,SAASC,EAAM,IAAIC,EAAoB;AAE/C,SACE,gBAAAC,EAAAC,GAAA,EAAS,SAAQ,SAAQ,WAAWT,EAAuB,EAAE,WAAAG,GAAW,OAAAG,EAAO,CAAA,GAAI,GAAGD,GACrF,UAAAD,EACF,CAAA;AAEF;AAEAF,EAAiB,cAAc;"}
|
|
@@ -7,15 +7,15 @@ import { P as H, D as K } from "./index-Bwf2hSw6.js";
|
|
|
7
7
|
import { h as W, R as j, u as U, F as V } from "./index-BdXokVmb.js";
|
|
8
8
|
import { u as Z } from "./index-xqkGMOJ8.js";
|
|
9
9
|
import { c as _, R as q, A as x, C as J, a as Q } from "./index-C3surxzg.js";
|
|
10
|
-
import { P as
|
|
11
|
-
import { P as
|
|
10
|
+
import { P as b } from "./index-BGfrl8IX.js";
|
|
11
|
+
import { P as w } from "./index-CpDnqHCm.js";
|
|
12
12
|
import { T as X } from "./index-BVqs-uqP.js";
|
|
13
13
|
import { c as Y } from "./cn-dsXlqdJg.js";
|
|
14
14
|
import { u as oo } from "./usePortalContainer-ae6EzS08.js";
|
|
15
15
|
import { T as eo } from "./TriggerButton-a2ClSj7f.js";
|
|
16
|
-
var C = "Popover", [
|
|
16
|
+
var C = "Popover", [y, Mo] = G(C, [
|
|
17
17
|
_
|
|
18
|
-
]), m = _(), [ro, l] =
|
|
18
|
+
]), m = _(), [ro, l] = y(C), E = (o) => {
|
|
19
19
|
const {
|
|
20
20
|
__scopePopover: n,
|
|
21
21
|
children: e,
|
|
@@ -46,18 +46,18 @@ var C = "Popover", [E, Mo] = G(C, [
|
|
|
46
46
|
}
|
|
47
47
|
) });
|
|
48
48
|
};
|
|
49
|
-
|
|
50
|
-
var
|
|
49
|
+
E.displayName = C;
|
|
50
|
+
var N = "PopoverAnchor", F = i.forwardRef(
|
|
51
51
|
(o, n) => {
|
|
52
|
-
const { __scopePopover: e, ...a } = o, r = l(
|
|
52
|
+
const { __scopePopover: e, ...a } = o, r = l(N, e), t = m(e), { onCustomAnchorAdd: c, onCustomAnchorRemove: p } = r;
|
|
53
53
|
return i.useEffect(() => (c(), () => p()), [c, p]), /* @__PURE__ */ s(x, { ...t, ...a, ref: n });
|
|
54
54
|
}
|
|
55
55
|
);
|
|
56
|
-
F.displayName =
|
|
56
|
+
F.displayName = N;
|
|
57
57
|
var S = "PopoverTrigger", T = i.forwardRef(
|
|
58
58
|
(o, n) => {
|
|
59
59
|
const { __scopePopover: e, ...a } = o, r = l(S, e), t = m(e), c = O(n, r.triggerRef), p = /* @__PURE__ */ s(
|
|
60
|
-
|
|
60
|
+
w.button,
|
|
61
61
|
{
|
|
62
62
|
type: "button",
|
|
63
63
|
"aria-haspopup": "dialog",
|
|
@@ -73,17 +73,17 @@ var S = "PopoverTrigger", T = i.forwardRef(
|
|
|
73
73
|
}
|
|
74
74
|
);
|
|
75
75
|
T.displayName = S;
|
|
76
|
-
var A = "PopoverPortal", [to, no] =
|
|
76
|
+
var A = "PopoverPortal", [to, no] = y(A, {
|
|
77
77
|
forceMount: void 0
|
|
78
78
|
}), D = (o) => {
|
|
79
79
|
const { __scopePopover: n, forceMount: e, children: a, container: r } = o, t = l(A, n);
|
|
80
|
-
return /* @__PURE__ */ s(to, { scope: n, forceMount: e, children: /* @__PURE__ */ s(
|
|
80
|
+
return /* @__PURE__ */ s(to, { scope: n, forceMount: e, children: /* @__PURE__ */ s(b, { present: e || t.open, children: /* @__PURE__ */ s(H, { asChild: !0, container: r, children: a }) }) });
|
|
81
81
|
};
|
|
82
82
|
D.displayName = A;
|
|
83
83
|
var d = "PopoverContent", M = i.forwardRef(
|
|
84
84
|
(o, n) => {
|
|
85
85
|
const e = no(d, o.__scopePopover), { forceMount: a = e.forceMount, ...r } = o, t = l(d, o.__scopePopover);
|
|
86
|
-
return /* @__PURE__ */ s(
|
|
86
|
+
return /* @__PURE__ */ s(b, { present: a || t.open, children: t.modal ? /* @__PURE__ */ s(so, { ...r, ref: n }) : /* @__PURE__ */ s(co, { ...r, ref: n }) });
|
|
87
87
|
}
|
|
88
88
|
);
|
|
89
89
|
M.displayName = d;
|
|
@@ -200,7 +200,7 @@ var ao = B("PopoverContent.RemoveScroll"), so = i.forwardRef(
|
|
|
200
200
|
(o, n) => {
|
|
201
201
|
const { __scopePopover: e, ...a } = o, r = l(I, e);
|
|
202
202
|
return /* @__PURE__ */ s(
|
|
203
|
-
|
|
203
|
+
w.button,
|
|
204
204
|
{
|
|
205
205
|
type: "button",
|
|
206
206
|
...a,
|
|
@@ -221,9 +221,9 @@ lo.displayName = po;
|
|
|
221
221
|
function $(o) {
|
|
222
222
|
return o ? "open" : "closed";
|
|
223
223
|
}
|
|
224
|
-
var uo =
|
|
224
|
+
var uo = E, fo = F, vo = T, Po = D, L = M;
|
|
225
225
|
const mo = X({
|
|
226
|
-
base: "
|
|
226
|
+
base: "z-50 w-72 origin-[--radix-popover-content-transform-origin] rounded-lg border border-secondary-border bg-secondary-bg p-4 text-popover-foreground shadow-soft-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2"
|
|
227
227
|
}), ko = uo, go = vo, Io = fo, ho = i.forwardRef(
|
|
228
228
|
({ className: o, align: n = "center", sideOffset: e = 4, portalContainer: a, ...r }, t) => {
|
|
229
229
|
const c = oo(a);
|
|
@@ -255,4 +255,4 @@ export {
|
|
|
255
255
|
Io as c,
|
|
256
256
|
Co as d
|
|
257
257
|
};
|
|
258
|
-
//# sourceMappingURL=Popover-
|
|
258
|
+
//# sourceMappingURL=Popover-DmwXZwYd.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Popover-CcZCvF57.js","sources":["../node_modules/.pnpm/@radix-ui+react-popover@1.1.15_@types+react-dom@18.3.6_@types+react@18.3.20__@types+react@18._yzidqq64zv67maddrn5ycxmur4/node_modules/@radix-ui/react-popover/dist/index.mjs","../src/components/popover/Popover.tsx"],"sourcesContent":["\"use client\";\n\n// src/popover.tsx\nimport * as React from \"react\";\nimport { composeEventHandlers } from \"@radix-ui/primitive\";\nimport { useComposedRefs } from \"@radix-ui/react-compose-refs\";\nimport { createContextScope } from \"@radix-ui/react-context\";\nimport { DismissableLayer } from \"@radix-ui/react-dismissable-layer\";\nimport { useFocusGuards } from \"@radix-ui/react-focus-guards\";\nimport { FocusScope } from \"@radix-ui/react-focus-scope\";\nimport { useId } from \"@radix-ui/react-id\";\nimport * as PopperPrimitive from \"@radix-ui/react-popper\";\nimport { createPopperScope } from \"@radix-ui/react-popper\";\nimport { Portal as PortalPrimitive } from \"@radix-ui/react-portal\";\nimport { Presence } from \"@radix-ui/react-presence\";\nimport { Primitive } from \"@radix-ui/react-primitive\";\nimport { createSlot } from \"@radix-ui/react-slot\";\nimport { useControllableState } from \"@radix-ui/react-use-controllable-state\";\nimport { hideOthers } from \"aria-hidden\";\nimport { RemoveScroll } from \"react-remove-scroll\";\nimport { jsx } from \"react/jsx-runtime\";\nvar POPOVER_NAME = \"Popover\";\nvar [createPopoverContext, createPopoverScope] = createContextScope(POPOVER_NAME, [\n createPopperScope\n]);\nvar usePopperScope = createPopperScope();\nvar [PopoverProvider, usePopoverContext] = createPopoverContext(POPOVER_NAME);\nvar Popover = (props) => {\n const {\n __scopePopover,\n children,\n open: openProp,\n defaultOpen,\n onOpenChange,\n modal = false\n } = props;\n const popperScope = usePopperScope(__scopePopover);\n const triggerRef = React.useRef(null);\n const [hasCustomAnchor, setHasCustomAnchor] = React.useState(false);\n const [open, setOpen] = useControllableState({\n prop: openProp,\n defaultProp: defaultOpen ?? false,\n onChange: onOpenChange,\n caller: POPOVER_NAME\n });\n return /* @__PURE__ */ jsx(PopperPrimitive.Root, { ...popperScope, children: /* @__PURE__ */ jsx(\n PopoverProvider,\n {\n scope: __scopePopover,\n contentId: useId(),\n triggerRef,\n open,\n onOpenChange: setOpen,\n onOpenToggle: React.useCallback(() => setOpen((prevOpen) => !prevOpen), [setOpen]),\n hasCustomAnchor,\n onCustomAnchorAdd: React.useCallback(() => setHasCustomAnchor(true), []),\n onCustomAnchorRemove: React.useCallback(() => setHasCustomAnchor(false), []),\n modal,\n children\n }\n ) });\n};\nPopover.displayName = POPOVER_NAME;\nvar ANCHOR_NAME = \"PopoverAnchor\";\nvar PopoverAnchor = React.forwardRef(\n (props, forwardedRef) => {\n const { __scopePopover, ...anchorProps } = props;\n const context = usePopoverContext(ANCHOR_NAME, __scopePopover);\n const popperScope = usePopperScope(__scopePopover);\n const { onCustomAnchorAdd, onCustomAnchorRemove } = context;\n React.useEffect(() => {\n onCustomAnchorAdd();\n return () => onCustomAnchorRemove();\n }, [onCustomAnchorAdd, onCustomAnchorRemove]);\n return /* @__PURE__ */ jsx(PopperPrimitive.Anchor, { ...popperScope, ...anchorProps, ref: forwardedRef });\n }\n);\nPopoverAnchor.displayName = ANCHOR_NAME;\nvar TRIGGER_NAME = \"PopoverTrigger\";\nvar PopoverTrigger = React.forwardRef(\n (props, forwardedRef) => {\n const { __scopePopover, ...triggerProps } = props;\n const context = usePopoverContext(TRIGGER_NAME, __scopePopover);\n const popperScope = usePopperScope(__scopePopover);\n const composedTriggerRef = useComposedRefs(forwardedRef, context.triggerRef);\n const trigger = /* @__PURE__ */ jsx(\n Primitive.button,\n {\n type: \"button\",\n \"aria-haspopup\": \"dialog\",\n \"aria-expanded\": context.open,\n \"aria-controls\": context.contentId,\n \"data-state\": getState(context.open),\n ...triggerProps,\n ref: composedTriggerRef,\n onClick: composeEventHandlers(props.onClick, context.onOpenToggle)\n }\n );\n return context.hasCustomAnchor ? trigger : /* @__PURE__ */ jsx(PopperPrimitive.Anchor, { asChild: true, ...popperScope, children: trigger });\n }\n);\nPopoverTrigger.displayName = TRIGGER_NAME;\nvar PORTAL_NAME = \"PopoverPortal\";\nvar [PortalProvider, usePortalContext] = createPopoverContext(PORTAL_NAME, {\n forceMount: void 0\n});\nvar PopoverPortal = (props) => {\n const { __scopePopover, forceMount, children, container } = props;\n const context = usePopoverContext(PORTAL_NAME, __scopePopover);\n return /* @__PURE__ */ jsx(PortalProvider, { scope: __scopePopover, forceMount, children: /* @__PURE__ */ jsx(Presence, { present: forceMount || context.open, children: /* @__PURE__ */ jsx(PortalPrimitive, { asChild: true, container, children }) }) });\n};\nPopoverPortal.displayName = PORTAL_NAME;\nvar CONTENT_NAME = \"PopoverContent\";\nvar PopoverContent = React.forwardRef(\n (props, forwardedRef) => {\n const portalContext = usePortalContext(CONTENT_NAME, props.__scopePopover);\n const { forceMount = portalContext.forceMount, ...contentProps } = props;\n const context = usePopoverContext(CONTENT_NAME, props.__scopePopover);\n return /* @__PURE__ */ jsx(Presence, { present: forceMount || context.open, children: context.modal ? /* @__PURE__ */ jsx(PopoverContentModal, { ...contentProps, ref: forwardedRef }) : /* @__PURE__ */ jsx(PopoverContentNonModal, { ...contentProps, ref: forwardedRef }) });\n }\n);\nPopoverContent.displayName = CONTENT_NAME;\nvar Slot = createSlot(\"PopoverContent.RemoveScroll\");\nvar PopoverContentModal = React.forwardRef(\n (props, forwardedRef) => {\n const context = usePopoverContext(CONTENT_NAME, props.__scopePopover);\n const contentRef = React.useRef(null);\n const composedRefs = useComposedRefs(forwardedRef, contentRef);\n const isRightClickOutsideRef = React.useRef(false);\n React.useEffect(() => {\n const content = contentRef.current;\n if (content) return hideOthers(content);\n }, []);\n return /* @__PURE__ */ jsx(RemoveScroll, { as: Slot, allowPinchZoom: true, children: /* @__PURE__ */ jsx(\n PopoverContentImpl,\n {\n ...props,\n ref: composedRefs,\n trapFocus: context.open,\n disableOutsidePointerEvents: true,\n onCloseAutoFocus: composeEventHandlers(props.onCloseAutoFocus, (event) => {\n event.preventDefault();\n if (!isRightClickOutsideRef.current) context.triggerRef.current?.focus();\n }),\n onPointerDownOutside: composeEventHandlers(\n props.onPointerDownOutside,\n (event) => {\n const originalEvent = event.detail.originalEvent;\n const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true;\n const isRightClick = originalEvent.button === 2 || ctrlLeftClick;\n isRightClickOutsideRef.current = isRightClick;\n },\n { checkForDefaultPrevented: false }\n ),\n onFocusOutside: composeEventHandlers(\n props.onFocusOutside,\n (event) => event.preventDefault(),\n { checkForDefaultPrevented: false }\n )\n }\n ) });\n }\n);\nvar PopoverContentNonModal = React.forwardRef(\n (props, forwardedRef) => {\n const context = usePopoverContext(CONTENT_NAME, props.__scopePopover);\n const hasInteractedOutsideRef = React.useRef(false);\n const hasPointerDownOutsideRef = React.useRef(false);\n return /* @__PURE__ */ jsx(\n PopoverContentImpl,\n {\n ...props,\n ref: forwardedRef,\n trapFocus: false,\n disableOutsidePointerEvents: false,\n onCloseAutoFocus: (event) => {\n props.onCloseAutoFocus?.(event);\n if (!event.defaultPrevented) {\n if (!hasInteractedOutsideRef.current) context.triggerRef.current?.focus();\n event.preventDefault();\n }\n hasInteractedOutsideRef.current = false;\n hasPointerDownOutsideRef.current = false;\n },\n onInteractOutside: (event) => {\n props.onInteractOutside?.(event);\n if (!event.defaultPrevented) {\n hasInteractedOutsideRef.current = true;\n if (event.detail.originalEvent.type === \"pointerdown\") {\n hasPointerDownOutsideRef.current = true;\n }\n }\n const target = event.target;\n const targetIsTrigger = context.triggerRef.current?.contains(target);\n if (targetIsTrigger) event.preventDefault();\n if (event.detail.originalEvent.type === \"focusin\" && hasPointerDownOutsideRef.current) {\n event.preventDefault();\n }\n }\n }\n );\n }\n);\nvar PopoverContentImpl = React.forwardRef(\n (props, forwardedRef) => {\n const {\n __scopePopover,\n trapFocus,\n onOpenAutoFocus,\n onCloseAutoFocus,\n disableOutsidePointerEvents,\n onEscapeKeyDown,\n onPointerDownOutside,\n onFocusOutside,\n onInteractOutside,\n ...contentProps\n } = props;\n const context = usePopoverContext(CONTENT_NAME, __scopePopover);\n const popperScope = usePopperScope(__scopePopover);\n useFocusGuards();\n return /* @__PURE__ */ jsx(\n FocusScope,\n {\n asChild: true,\n loop: true,\n trapped: trapFocus,\n onMountAutoFocus: onOpenAutoFocus,\n onUnmountAutoFocus: onCloseAutoFocus,\n children: /* @__PURE__ */ jsx(\n DismissableLayer,\n {\n asChild: true,\n disableOutsidePointerEvents,\n onInteractOutside,\n onEscapeKeyDown,\n onPointerDownOutside,\n onFocusOutside,\n onDismiss: () => context.onOpenChange(false),\n children: /* @__PURE__ */ jsx(\n PopperPrimitive.Content,\n {\n \"data-state\": getState(context.open),\n role: \"dialog\",\n id: context.contentId,\n ...popperScope,\n ...contentProps,\n ref: forwardedRef,\n style: {\n ...contentProps.style,\n // re-namespace exposed content custom properties\n ...{\n \"--radix-popover-content-transform-origin\": \"var(--radix-popper-transform-origin)\",\n \"--radix-popover-content-available-width\": \"var(--radix-popper-available-width)\",\n \"--radix-popover-content-available-height\": \"var(--radix-popper-available-height)\",\n \"--radix-popover-trigger-width\": \"var(--radix-popper-anchor-width)\",\n \"--radix-popover-trigger-height\": \"var(--radix-popper-anchor-height)\"\n }\n }\n }\n )\n }\n )\n }\n );\n }\n);\nvar CLOSE_NAME = \"PopoverClose\";\nvar PopoverClose = React.forwardRef(\n (props, forwardedRef) => {\n const { __scopePopover, ...closeProps } = props;\n const context = usePopoverContext(CLOSE_NAME, __scopePopover);\n return /* @__PURE__ */ jsx(\n Primitive.button,\n {\n type: \"button\",\n ...closeProps,\n ref: forwardedRef,\n onClick: composeEventHandlers(props.onClick, () => context.onOpenChange(false))\n }\n );\n }\n);\nPopoverClose.displayName = CLOSE_NAME;\nvar ARROW_NAME = \"PopoverArrow\";\nvar PopoverArrow = React.forwardRef(\n (props, forwardedRef) => {\n const { __scopePopover, ...arrowProps } = props;\n const popperScope = usePopperScope(__scopePopover);\n return /* @__PURE__ */ jsx(PopperPrimitive.Arrow, { ...popperScope, ...arrowProps, ref: forwardedRef });\n }\n);\nPopoverArrow.displayName = ARROW_NAME;\nfunction getState(open) {\n return open ? \"open\" : \"closed\";\n}\nvar Root2 = Popover;\nvar Anchor2 = PopoverAnchor;\nvar Trigger = PopoverTrigger;\nvar Portal = PopoverPortal;\nvar Content2 = PopoverContent;\nvar Close = PopoverClose;\nvar Arrow2 = PopoverArrow;\nexport {\n Anchor2 as Anchor,\n Arrow2 as Arrow,\n Close,\n Content2 as Content,\n Popover,\n PopoverAnchor,\n PopoverArrow,\n PopoverClose,\n PopoverContent,\n PopoverPortal,\n PopoverTrigger,\n Portal,\n Root2 as Root,\n Trigger,\n createPopoverScope\n};\n//# sourceMappingURL=index.mjs.map\n","import * as React from \"react\";\nimport * as PopoverPrimitive from \"@radix-ui/react-popover\";\nimport { tv } from \"tailwind-variants\";\nimport { cn } from \"@/lib/utils\";\nimport { usePortalContainer } from \"../portal-container\";\nimport { TriggerButton } from \"../button\";\nimport { TriggerButtonProps } from \"../button/trigger-button/TriggerButton\";\n\nconst popoverStyles = tv({\n\tbase: \"shadow-soft-md z-50 w-72 origin-[--radix-popover-content-transform-origin] rounded-lg border bg-popover p-4 text-popover-foreground outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2\"\n});\n\ntype PopoverContentProps = React.ComponentPropsWithoutRef<typeof PopoverPrimitive.Content> & {\n\t/**\n\t * Контейнер для портала. Если не указан, используется хук usePortalContainer\n\t * для поиска PortalContainer\n\t */\n\tportalContainer?: HTMLElement;\n};\n\n/**\n * Корневой компонент Popover, который оборачивает всю функциональность всплывающего окна.\n * Построен на основе Radix UI Popover primitive.\n */\nconst Popover = PopoverPrimitive.Root;\n\n/**\n * Элемент-триггер, который открывает всплывающее окно при клике.\n */\nconst PopoverTrigger = PopoverPrimitive.Trigger;\n\n/**\n * Элемент-якорь, относительно которого позиционируется всплывающее окно.\n */\nconst PopoverAnchor = PopoverPrimitive.Anchor;\n\n/**\n * Компонент содержимого всплывающего окна.\n */\nconst PopoverContent = React.forwardRef<React.ElementRef<typeof PopoverPrimitive.Content>, PopoverContentProps>(\n\t({ className, align = \"center\", sideOffset = 4, portalContainer, ...props }, ref) => {\n\t\tconst container = usePortalContainer(portalContainer);\n\t\treturn (\n\t\t\t<PopoverPrimitive.Portal container={container}>\n\t\t\t\t<PopoverPrimitive.Content\n\t\t\t\t\t// Фикс скроллинга внутри Popover когда он находится в Dialog\n\t\t\t\t\t// RemoveScroll в Dialog блокирует прокрутку body, но может блокировать и вложенные элементы\n\t\t\t\t\t// stopPropagation предотвращает всплытие событий скроллинга к заблокированному body\n\t\t\t\t\t// https://github.com/radix-ui/primitives/issues/1159\n\t\t\t\t\tonWheel={(e) => {\n\t\t\t\t\t\te.stopPropagation();\n\t\t\t\t\t}}\n\t\t\t\t\tonTouchMove={(e) => {\n\t\t\t\t\t\te.stopPropagation();\n\t\t\t\t\t}}\n\t\t\t\t\tref={ref}\n\t\t\t\t\talign={align}\n\t\t\t\t\tsideOffset={sideOffset}\n\t\t\t\t\tclassName={cn(popoverStyles(), className)}\n\t\t\t\t\t{...props}\n\t\t\t\t/>\n\t\t\t</PopoverPrimitive.Portal>\n\t\t);\n\t}\n);\nPopoverContent.displayName = PopoverPrimitive.Content.displayName;\n\n/**\n * Компонент-обертка для использования TriggerButton в качестве триггера поповера\n */\nconst PopoverTriggerButton = React.forwardRef<\n\tReact.ElementRef<typeof PopoverTrigger>,\n\tReact.ComponentPropsWithoutRef<typeof PopoverTrigger> & Omit<TriggerButtonProps, \"dataState\">\n>(({ children, ...props }, ref) => {\n\treturn (\n\t\t<PopoverTrigger asChild ref={ref}>\n\t\t\t<TriggerButton {...props}>{children}</TriggerButton>\n\t\t</PopoverTrigger>\n\t);\n});\n\nPopoverTriggerButton.displayName = \"PopoverTriggerButton\";\n\nexport { Popover, PopoverTrigger, PopoverContent, PopoverAnchor, PopoverTriggerButton };\n"],"names":["POPOVER_NAME","createPopoverContext","createPopoverScope","createContextScope","createPopperScope","usePopperScope","PopoverProvider","usePopoverContext","Popover","props","__scopePopover","children","openProp","defaultOpen","onOpenChange","modal","popperScope","triggerRef","React","hasCustomAnchor","setHasCustomAnchor","open","setOpen","useControllableState","jsx","PopperPrimitive.Root","useId","prevOpen","ANCHOR_NAME","PopoverAnchor","forwardedRef","anchorProps","context","onCustomAnchorAdd","onCustomAnchorRemove","PopperPrimitive.Anchor","TRIGGER_NAME","PopoverTrigger","triggerProps","composedTriggerRef","useComposedRefs","trigger","Primitive","getState","composeEventHandlers","PORTAL_NAME","PortalProvider","usePortalContext","PopoverPortal","forceMount","container","Presence","PortalPrimitive","CONTENT_NAME","PopoverContent","portalContext","contentProps","PopoverContentModal","PopoverContentNonModal","Slot","createSlot","contentRef","composedRefs","isRightClickOutsideRef","content","hideOthers","RemoveScroll","PopoverContentImpl","event","originalEvent","ctrlLeftClick","isRightClick","hasInteractedOutsideRef","hasPointerDownOutsideRef","target","trapFocus","onOpenAutoFocus","onCloseAutoFocus","disableOutsidePointerEvents","onEscapeKeyDown","onPointerDownOutside","onFocusOutside","onInteractOutside","useFocusGuards","FocusScope","DismissableLayer","PopperPrimitive.Content","CLOSE_NAME","PopoverClose","closeProps","ARROW_NAME","PopoverArrow","arrowProps","PopperPrimitive.Arrow","Root2","Anchor2","Trigger","Portal","Content2","popoverStyles","tv","PopoverPrimitive.Root","PopoverPrimitive.Trigger","PopoverPrimitive.Anchor","className","align","sideOffset","portalContainer","ref","usePortalContainer","PopoverPrimitive.Portal","PopoverPrimitive.Content","e","cn","PopoverTriggerButton","TriggerButton"],"mappings":";;;;;;;;;;;;;;;AAqBA,IAAIA,IAAe,WACf,CAACC,GAAsBC,EAAkB,IAAIC,EAAmBH,GAAc;AAAA,EAChFI;AACF,CAAC,GACGC,IAAiBD,EAAmB,GACpC,CAACE,IAAiBC,CAAiB,IAAIN,EAAq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AAW,OAAAC,IAAQ,UAAU,YAAAC,IAAa,GAAG,iBAAAC,GAAiB,GAAGlG,EAAM,GAAGmG,MAAQ;AAC9E,UAAA1D,IAAY2D,GAAmBF,CAAe;AACpD,WACE,gBAAAnF,EAAAsF,IAAA,EAAwB,WAAA5D,GACxB,UAAA,gBAAA1B;AAAA,MAACuF;AAAAA,MAAA;AAAA,QAKA,SAAS,CAACC,MAAM;AACf,UAAAA,EAAE,gBAAgB;AAAA,QACnB;AAAA,QACA,aAAa,CAACA,MAAM;AACnB,UAAAA,EAAE,gBAAgB;AAAA,QACnB;AAAA,QACA,KAAAJ;AAAA,QACA,OAAAH;AAAA,QACA,YAAAC;AAAA,QACA,WAAWO,EAAGd,GAAc,GAAGK,CAAS;AAAA,QACvC,GAAG/F;AAAA,MAAA;AAAA,IAAA,GAEN;AAAA,EAAA;AAGH;AACA6C,GAAe,cAAcyD,EAAyB;AAKhD,MAAAG,KAAuBhG,EAAM,WAGjC,CAAC,EAAE,UAAAP,GAAU,GAAGF,EAAM,GAAGmG,MAEzB,gBAAApF,EAACa,IAAe,EAAA,SAAO,IAAC,KAAAuE,GACvB,4BAACO,IAAe,EAAA,GAAG1G,GAAQ,UAAAE,EAAA,CAAS,EACrC,CAAA,CAED;AAEDuG,GAAqB,cAAc;","x_google_ignoreList":[0]}
|
|
1
|
+
{"version":3,"file":"Popover-DmwXZwYd.js","sources":["../node_modules/.pnpm/@radix-ui+react-popover@1.1.15_@types+react-dom@18.3.6_@types+react@18.3.20__@types+react@18._yzidqq64zv67maddrn5ycxmur4/node_modules/@radix-ui/react-popover/dist/index.mjs","../src/components/popover/Popover.tsx"],"sourcesContent":["\"use client\";\n\n// src/popover.tsx\nimport * as React from \"react\";\nimport { composeEventHandlers } from \"@radix-ui/primitive\";\nimport { useComposedRefs } from \"@radix-ui/react-compose-refs\";\nimport { createContextScope } from \"@radix-ui/react-context\";\nimport { DismissableLayer } from \"@radix-ui/react-dismissable-layer\";\nimport { useFocusGuards } from \"@radix-ui/react-focus-guards\";\nimport { FocusScope } from \"@radix-ui/react-focus-scope\";\nimport { useId } from \"@radix-ui/react-id\";\nimport * as PopperPrimitive from \"@radix-ui/react-popper\";\nimport { createPopperScope } from \"@radix-ui/react-popper\";\nimport { Portal as PortalPrimitive } from \"@radix-ui/react-portal\";\nimport { Presence } from \"@radix-ui/react-presence\";\nimport { Primitive } from \"@radix-ui/react-primitive\";\nimport { createSlot } from \"@radix-ui/react-slot\";\nimport { useControllableState } from \"@radix-ui/react-use-controllable-state\";\nimport { hideOthers } from \"aria-hidden\";\nimport { RemoveScroll } from \"react-remove-scroll\";\nimport { jsx } from \"react/jsx-runtime\";\nvar POPOVER_NAME = \"Popover\";\nvar [createPopoverContext, createPopoverScope] = createContextScope(POPOVER_NAME, [\n createPopperScope\n]);\nvar usePopperScope = createPopperScope();\nvar [PopoverProvider, usePopoverContext] = createPopoverContext(POPOVER_NAME);\nvar Popover = (props) => {\n const {\n __scopePopover,\n children,\n open: openProp,\n defaultOpen,\n onOpenChange,\n modal = false\n } = props;\n const popperScope = usePopperScope(__scopePopover);\n const triggerRef = React.useRef(null);\n const [hasCustomAnchor, setHasCustomAnchor] = React.useState(false);\n const [open, setOpen] = useControllableState({\n prop: openProp,\n defaultProp: defaultOpen ?? false,\n onChange: onOpenChange,\n caller: POPOVER_NAME\n });\n return /* @__PURE__ */ jsx(PopperPrimitive.Root, { ...popperScope, children: /* @__PURE__ */ jsx(\n PopoverProvider,\n {\n scope: __scopePopover,\n contentId: useId(),\n triggerRef,\n open,\n onOpenChange: setOpen,\n onOpenToggle: React.useCallback(() => setOpen((prevOpen) => !prevOpen), [setOpen]),\n hasCustomAnchor,\n onCustomAnchorAdd: React.useCallback(() => setHasCustomAnchor(true), []),\n onCustomAnchorRemove: React.useCallback(() => setHasCustomAnchor(false), []),\n modal,\n children\n }\n ) });\n};\nPopover.displayName = POPOVER_NAME;\nvar ANCHOR_NAME = \"PopoverAnchor\";\nvar PopoverAnchor = React.forwardRef(\n (props, forwardedRef) => {\n const { __scopePopover, ...anchorProps } = props;\n const context = usePopoverContext(ANCHOR_NAME, __scopePopover);\n const popperScope = usePopperScope(__scopePopover);\n const { onCustomAnchorAdd, onCustomAnchorRemove } = context;\n React.useEffect(() => {\n onCustomAnchorAdd();\n return () => onCustomAnchorRemove();\n }, [onCustomAnchorAdd, onCustomAnchorRemove]);\n return /* @__PURE__ */ jsx(PopperPrimitive.Anchor, { ...popperScope, ...anchorProps, ref: forwardedRef });\n }\n);\nPopoverAnchor.displayName = ANCHOR_NAME;\nvar TRIGGER_NAME = \"PopoverTrigger\";\nvar PopoverTrigger = React.forwardRef(\n (props, forwardedRef) => {\n const { __scopePopover, ...triggerProps } = props;\n const context = usePopoverContext(TRIGGER_NAME, __scopePopover);\n const popperScope = usePopperScope(__scopePopover);\n const composedTriggerRef = useComposedRefs(forwardedRef, context.triggerRef);\n const trigger = /* @__PURE__ */ jsx(\n Primitive.button,\n {\n type: \"button\",\n \"aria-haspopup\": \"dialog\",\n \"aria-expanded\": context.open,\n \"aria-controls\": context.contentId,\n \"data-state\": getState(context.open),\n ...triggerProps,\n ref: composedTriggerRef,\n onClick: composeEventHandlers(props.onClick, context.onOpenToggle)\n }\n );\n return context.hasCustomAnchor ? trigger : /* @__PURE__ */ jsx(PopperPrimitive.Anchor, { asChild: true, ...popperScope, children: trigger });\n }\n);\nPopoverTrigger.displayName = TRIGGER_NAME;\nvar PORTAL_NAME = \"PopoverPortal\";\nvar [PortalProvider, usePortalContext] = createPopoverContext(PORTAL_NAME, {\n forceMount: void 0\n});\nvar PopoverPortal = (props) => {\n const { __scopePopover, forceMount, children, container } = props;\n const context = usePopoverContext(PORTAL_NAME, __scopePopover);\n return /* @__PURE__ */ jsx(PortalProvider, { scope: __scopePopover, forceMount, children: /* @__PURE__ */ jsx(Presence, { present: forceMount || context.open, children: /* @__PURE__ */ jsx(PortalPrimitive, { asChild: true, container, children }) }) });\n};\nPopoverPortal.displayName = PORTAL_NAME;\nvar CONTENT_NAME = \"PopoverContent\";\nvar PopoverContent = React.forwardRef(\n (props, forwardedRef) => {\n const portalContext = usePortalContext(CONTENT_NAME, props.__scopePopover);\n const { forceMount = portalContext.forceMount, ...contentProps } = props;\n const context = usePopoverContext(CONTENT_NAME, props.__scopePopover);\n return /* @__PURE__ */ jsx(Presence, { present: forceMount || context.open, children: context.modal ? /* @__PURE__ */ jsx(PopoverContentModal, { ...contentProps, ref: forwardedRef }) : /* @__PURE__ */ jsx(PopoverContentNonModal, { ...contentProps, ref: forwardedRef }) });\n }\n);\nPopoverContent.displayName = CONTENT_NAME;\nvar Slot = createSlot(\"PopoverContent.RemoveScroll\");\nvar PopoverContentModal = React.forwardRef(\n (props, forwardedRef) => {\n const context = usePopoverContext(CONTENT_NAME, props.__scopePopover);\n const contentRef = React.useRef(null);\n const composedRefs = useComposedRefs(forwardedRef, contentRef);\n const isRightClickOutsideRef = React.useRef(false);\n React.useEffect(() => {\n const content = contentRef.current;\n if (content) return hideOthers(content);\n }, []);\n return /* @__PURE__ */ jsx(RemoveScroll, { as: Slot, allowPinchZoom: true, children: /* @__PURE__ */ jsx(\n PopoverContentImpl,\n {\n ...props,\n ref: composedRefs,\n trapFocus: context.open,\n disableOutsidePointerEvents: true,\n onCloseAutoFocus: composeEventHandlers(props.onCloseAutoFocus, (event) => {\n event.preventDefault();\n if (!isRightClickOutsideRef.current) context.triggerRef.current?.focus();\n }),\n onPointerDownOutside: composeEventHandlers(\n props.onPointerDownOutside,\n (event) => {\n const originalEvent = event.detail.originalEvent;\n const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true;\n const isRightClick = originalEvent.button === 2 || ctrlLeftClick;\n isRightClickOutsideRef.current = isRightClick;\n },\n { checkForDefaultPrevented: false }\n ),\n onFocusOutside: composeEventHandlers(\n props.onFocusOutside,\n (event) => event.preventDefault(),\n { checkForDefaultPrevented: false }\n )\n }\n ) });\n }\n);\nvar PopoverContentNonModal = React.forwardRef(\n (props, forwardedRef) => {\n const context = usePopoverContext(CONTENT_NAME, props.__scopePopover);\n const hasInteractedOutsideRef = React.useRef(false);\n const hasPointerDownOutsideRef = React.useRef(false);\n return /* @__PURE__ */ jsx(\n PopoverContentImpl,\n {\n ...props,\n ref: forwardedRef,\n trapFocus: false,\n disableOutsidePointerEvents: false,\n onCloseAutoFocus: (event) => {\n props.onCloseAutoFocus?.(event);\n if (!event.defaultPrevented) {\n if (!hasInteractedOutsideRef.current) context.triggerRef.current?.focus();\n event.preventDefault();\n }\n hasInteractedOutsideRef.current = false;\n hasPointerDownOutsideRef.current = false;\n },\n onInteractOutside: (event) => {\n props.onInteractOutside?.(event);\n if (!event.defaultPrevented) {\n hasInteractedOutsideRef.current = true;\n if (event.detail.originalEvent.type === \"pointerdown\") {\n hasPointerDownOutsideRef.current = true;\n }\n }\n const target = event.target;\n const targetIsTrigger = context.triggerRef.current?.contains(target);\n if (targetIsTrigger) event.preventDefault();\n if (event.detail.originalEvent.type === \"focusin\" && hasPointerDownOutsideRef.current) {\n event.preventDefault();\n }\n }\n }\n );\n }\n);\nvar PopoverContentImpl = React.forwardRef(\n (props, forwardedRef) => {\n const {\n __scopePopover,\n trapFocus,\n onOpenAutoFocus,\n onCloseAutoFocus,\n disableOutsidePointerEvents,\n onEscapeKeyDown,\n onPointerDownOutside,\n onFocusOutside,\n onInteractOutside,\n ...contentProps\n } = props;\n const context = usePopoverContext(CONTENT_NAME, __scopePopover);\n const popperScope = usePopperScope(__scopePopover);\n useFocusGuards();\n return /* @__PURE__ */ jsx(\n FocusScope,\n {\n asChild: true,\n loop: true,\n trapped: trapFocus,\n onMountAutoFocus: onOpenAutoFocus,\n onUnmountAutoFocus: onCloseAutoFocus,\n children: /* @__PURE__ */ jsx(\n DismissableLayer,\n {\n asChild: true,\n disableOutsidePointerEvents,\n onInteractOutside,\n onEscapeKeyDown,\n onPointerDownOutside,\n onFocusOutside,\n onDismiss: () => context.onOpenChange(false),\n children: /* @__PURE__ */ jsx(\n PopperPrimitive.Content,\n {\n \"data-state\": getState(context.open),\n role: \"dialog\",\n id: context.contentId,\n ...popperScope,\n ...contentProps,\n ref: forwardedRef,\n style: {\n ...contentProps.style,\n // re-namespace exposed content custom properties\n ...{\n \"--radix-popover-content-transform-origin\": \"var(--radix-popper-transform-origin)\",\n \"--radix-popover-content-available-width\": \"var(--radix-popper-available-width)\",\n \"--radix-popover-content-available-height\": \"var(--radix-popper-available-height)\",\n \"--radix-popover-trigger-width\": \"var(--radix-popper-anchor-width)\",\n \"--radix-popover-trigger-height\": \"var(--radix-popper-anchor-height)\"\n }\n }\n }\n )\n }\n )\n }\n );\n }\n);\nvar CLOSE_NAME = \"PopoverClose\";\nvar PopoverClose = React.forwardRef(\n (props, forwardedRef) => {\n const { __scopePopover, ...closeProps } = props;\n const context = usePopoverContext(CLOSE_NAME, __scopePopover);\n return /* @__PURE__ */ jsx(\n Primitive.button,\n {\n type: \"button\",\n ...closeProps,\n ref: forwardedRef,\n onClick: composeEventHandlers(props.onClick, () => context.onOpenChange(false))\n }\n );\n }\n);\nPopoverClose.displayName = CLOSE_NAME;\nvar ARROW_NAME = \"PopoverArrow\";\nvar PopoverArrow = React.forwardRef(\n (props, forwardedRef) => {\n const { __scopePopover, ...arrowProps } = props;\n const popperScope = usePopperScope(__scopePopover);\n return /* @__PURE__ */ jsx(PopperPrimitive.Arrow, { ...popperScope, ...arrowProps, ref: forwardedRef });\n }\n);\nPopoverArrow.displayName = ARROW_NAME;\nfunction getState(open) {\n return open ? \"open\" : \"closed\";\n}\nvar Root2 = Popover;\nvar Anchor2 = PopoverAnchor;\nvar Trigger = PopoverTrigger;\nvar Portal = PopoverPortal;\nvar Content2 = PopoverContent;\nvar Close = PopoverClose;\nvar Arrow2 = PopoverArrow;\nexport {\n Anchor2 as Anchor,\n Arrow2 as Arrow,\n Close,\n Content2 as Content,\n Popover,\n PopoverAnchor,\n PopoverArrow,\n PopoverClose,\n PopoverContent,\n PopoverPortal,\n PopoverTrigger,\n Portal,\n Root2 as Root,\n Trigger,\n createPopoverScope\n};\n//# sourceMappingURL=index.mjs.map\n","import * as React from \"react\";\nimport * as PopoverPrimitive from \"@radix-ui/react-popover\";\nimport { tv } from \"tailwind-variants\";\nimport { cn } from \"@/lib/utils\";\nimport { usePortalContainer } from \"../portal-container\";\nimport { TriggerButton } from \"../button\";\nimport { TriggerButtonProps } from \"../button/trigger-button/TriggerButton\";\n\nconst popoverStyles = tv({\n\tbase: \"z-50 w-72 origin-[--radix-popover-content-transform-origin] rounded-lg border border-secondary-border bg-secondary-bg p-4 text-popover-foreground shadow-soft-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2\"\n});\n\ntype PopoverContentProps = React.ComponentPropsWithoutRef<typeof PopoverPrimitive.Content> & {\n\t/**\n\t * Контейнер для портала. Если не указан, используется хук usePortalContainer\n\t * для поиска PortalContainer\n\t */\n\tportalContainer?: HTMLElement;\n};\n\n/**\n * Корневой компонент Popover, который оборачивает всю функциональность всплывающего окна.\n * Построен на основе Radix UI Popover primitive.\n */\nconst Popover = PopoverPrimitive.Root;\n\n/**\n * Элемент-триггер, который открывает всплывающее окно при клике.\n */\nconst PopoverTrigger = PopoverPrimitive.Trigger;\n\n/**\n * Элемент-якорь, относительно которого позиционируется всплывающее окно.\n */\nconst PopoverAnchor = PopoverPrimitive.Anchor;\n\n/**\n * Компонент содержимого всплывающего окна.\n */\nconst PopoverContent = React.forwardRef<React.ElementRef<typeof PopoverPrimitive.Content>, PopoverContentProps>(\n\t({ className, align = \"center\", sideOffset = 4, portalContainer, ...props }, ref) => {\n\t\tconst container = usePortalContainer(portalContainer);\n\t\treturn (\n\t\t\t<PopoverPrimitive.Portal container={container}>\n\t\t\t\t<PopoverPrimitive.Content\n\t\t\t\t\t// Фикс скроллинга внутри Popover когда он находится в Dialog\n\t\t\t\t\t// RemoveScroll в Dialog блокирует прокрутку body, но может блокировать и вложенные элементы\n\t\t\t\t\t// stopPropagation предотвращает всплытие событий скроллинга к заблокированному body\n\t\t\t\t\t// https://github.com/radix-ui/primitives/issues/1159\n\t\t\t\t\tonWheel={(e) => {\n\t\t\t\t\t\te.stopPropagation();\n\t\t\t\t\t}}\n\t\t\t\t\tonTouchMove={(e) => {\n\t\t\t\t\t\te.stopPropagation();\n\t\t\t\t\t}}\n\t\t\t\t\tref={ref}\n\t\t\t\t\talign={align}\n\t\t\t\t\tsideOffset={sideOffset}\n\t\t\t\t\tclassName={cn(popoverStyles(), className)}\n\t\t\t\t\t{...props}\n\t\t\t\t/>\n\t\t\t</PopoverPrimitive.Portal>\n\t\t);\n\t}\n);\nPopoverContent.displayName = PopoverPrimitive.Content.displayName;\n\n/**\n * Компонент-обертка для использования TriggerButton в качестве триггера поповера\n */\nconst PopoverTriggerButton = React.forwardRef<\n\tReact.ElementRef<typeof PopoverTrigger>,\n\tReact.ComponentPropsWithoutRef<typeof PopoverTrigger> & Omit<TriggerButtonProps, \"dataState\">\n>(({ children, ...props }, ref) => {\n\treturn (\n\t\t<PopoverTrigger asChild ref={ref}>\n\t\t\t<TriggerButton {...props}>{children}</TriggerButton>\n\t\t</PopoverTrigger>\n\t);\n});\n\nPopoverTriggerButton.displayName = \"PopoverTriggerButton\";\n\nexport { Popover, PopoverTrigger, PopoverContent, PopoverAnchor, PopoverTriggerButton };\n"],"names":["POPOVER_NAME","createPopoverContext","createPopoverScope","createContextScope","createPopperScope","usePopperScope","PopoverProvider","usePopoverContext","Popover","props","__scopePopover","children","openProp","defaultOpen","onOpenChange","modal","popperScope","triggerRef","React","hasCustomAnchor","setHasCustomAnchor","open","setOpen","useControllableState","jsx","PopperPrimitive.Root","useId","prevOpen","ANCHOR_NAME","PopoverAnchor","forwardedRef","anchorProps","context","onCustomAnchorAdd","onCustomAnchorRemove","PopperPrimitive.Anchor","TRIGGER_NAME","PopoverTrigger","triggerProps","composedTriggerRef","useComposedRefs","trigger","Primitive","getState","composeEventHandlers","PORTAL_NAME","PortalProvider","usePortalContext","PopoverPortal","forceMount","container","Presence","PortalPrimitive","CONTENT_NAME","PopoverContent","portalContext","contentProps","PopoverContentModal","PopoverContentNonModal","Slot","createSlot","contentRef","composedRefs","isRightClickOutsideRef","content","hideOthers","RemoveScroll","PopoverContentImpl","event","originalEvent","ctrlLeftClick","isRightClick","hasInteractedOutsideRef","hasPointerDownOutsideRef","target","trapFocus","onOpenAutoFocus","onCloseAutoFocus","disableOutsidePointerEvents","onEscapeKeyDown","onPointerDownOutside","onFocusOutside","onInteractOutside","useFocusGuards","FocusScope","DismissableLayer","PopperPrimitive.Content","CLOSE_NAME","PopoverClose","closeProps","ARROW_NAME","PopoverArrow","arrowProps","PopperPrimitive.Arrow","Root2","Anchor2","Trigger","Portal","Content2","popoverStyles","tv","PopoverPrimitive.Root","PopoverPrimitive.Trigger","PopoverPrimitive.Anchor","className","align","sideOffset","portalContainer","ref","usePortalContainer","PopoverPrimitive.Portal","PopoverPrimitive.Content","e","cn","PopoverTriggerButton","TriggerButton"],"mappings":";;;;;;;;;;;;;;;AAqBA,IAAIA,IAAe,WACf,CAACC,GAAsBC,EAAkB,IAAIC,EAAmBH,GAAc;AAAA,EAChFI;AACF,CAAC,GACGC,IAAiBD,EAAmB,GACpC,CAACE,IAAiBC,CAAiB,IAAIN,EAAqBD,CAAY,GACxEQ,IAAU,CAACC,MAAU;AACvB,QAAM;AAAA,IACJ,gBAAAC;AAAA,IACA,UAAAC;AAAA,IACA,MAAMC;AAAA,IACN,aAAAC;AAAA,IACA,cAAAC;AAAA,IACA,OAAAC,IAAQ;AAAA,EACZ,IAAMN,GACEO,IAAcX,EAAeK,CAAc,GAC3CO,IAAaC,EAAM,OAAO,IAAI,GAC9B,CAACC,GAAiBC,CAAkB,IAAIF,EAAM,SAAS,EAAK,GAC5D,CAACG,GA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ACA,MAAM;AACnB,UAAAA,EAAE,gBAAgB;AAAA,QACnB;AAAA,QACA,KAAAJ;AAAA,QACA,OAAAH;AAAA,QACA,YAAAC;AAAA,QACA,WAAWO,EAAGd,GAAc,GAAGK,CAAS;AAAA,QACvC,GAAG/F;AAAA,MAAA;AAAA,IAAA,GAEN;AAAA,EAAA;AAGH;AACA6C,GAAe,cAAcyD,EAAyB;AAKhD,MAAAG,KAAuBhG,EAAM,WAGjC,CAAC,EAAE,UAAAP,GAAU,GAAGF,EAAM,GAAGmG,MAEzB,gBAAApF,EAACa,IAAe,EAAA,SAAO,IAAC,KAAAuE,GACvB,4BAACO,IAAe,EAAA,GAAG1G,GAAQ,UAAAE,EAAA,CAAS,EACrC,CAAA,CAED;AAEDuG,GAAqB,cAAc;","x_google_ignoreList":[0]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useState as p, useCallback as h, useEffect as k, useMemo as C } from "react";
|
|
2
2
|
import { jsxs as g, jsx as i, Fragment as S } from "react/jsx-runtime";
|
|
3
|
-
import { d as T, a as D, c as I, b as w } from "./Tag-
|
|
3
|
+
import { d as T, a as D, c as I, b as w } from "./Tag-CofZF1d0.js";
|
|
4
4
|
import { u as y } from "./useBreakpoints-wEcfJPHd.js";
|
|
5
5
|
import { T as F } from "./index-BVqs-uqP.js";
|
|
6
6
|
function K({ value: e, defaultValue: c, onChange: s }) {
|
|
@@ -93,4 +93,4 @@ export {
|
|
|
93
93
|
L as a,
|
|
94
94
|
K as u
|
|
95
95
|
};
|
|
96
|
-
//# sourceMappingURL=SearchSelectTag-
|
|
96
|
+
//# sourceMappingURL=SearchSelectTag-Ce-Q9JGR.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchSelectTag-D1bFK1ux.js","sources":["../src/hooks/useControllableState.ts","../src/hooks/useItemsKeyboardNavigation.ts","../src/components/search-select/components/SearchSelectTag.tsx"],"sourcesContent":["import { useCallback, useState } from \"react\";\n\ntype UseControllableStateParams<T> = {\n\t/** Controlled значение */\n\tvalue?: T;\n\t/** Значение по умолчанию для uncontrolled режима */\n\tdefaultValue?: T;\n\t/** Callback при изменении значения */\n\tonChange?: (value: T) => void;\n};\n\n/**\n * Универсальный хук для управления controlled/uncontrolled состоянием.\n */\nexport function useControllableState<T>({ value, defaultValue, onChange }: UseControllableStateParams<T>) {\n\tconst [uncontrolledValue, setUncontrolledValue] = useState(defaultValue);\n\n\tconst isControlled = value !== undefined;\n\tconst actualValue = isControlled ? value : uncontrolledValue;\n\n\tconst setValue = useCallback(\n\t\t(nextValue: T | ((prevValue: T) => T)) => {\n\t\t\tconst resolvedValue =\n\t\t\t\ttypeof nextValue === \"function\" ? (nextValue as (prevValue: T) => T)(actualValue as T) : nextValue;\n\n\t\t\tif (!isControlled) {\n\t\t\t\tsetUncontrolledValue(resolvedValue);\n\t\t\t}\n\n\t\t\tonChange?.(resolvedValue);\n\t\t},\n\t\t[actualValue, isControlled, onChange]\n\t);\n\n\treturn [actualValue, setValue] as const;\n}\n","import { useCallback, useState, KeyboardEvent, useEffect } from \"react\";\n\n/**\n * Хук для навигации по элементам с помощью клавиатуры\n *\n * @example\n * ```tsx\n * function TagList({ tags, onTagSelect, onTagDelete }) {\n * const containerRef = useRef(null);\n *\n * const {\n * focusedIndex,\n * handleKeyDown,\n * handleFocus,\n * handleBlur,\n * isFocused\n * } = useItemsKeyboardNavigation({\n * items: tags,\n * onEnter: onTagSelect,\n * onDelete: onTagDelete\n * });\n *\n * return (\n * <div\n * ref={containerRef}\n * tabIndex={0}\n * onKeyDown={handleKeyDown}\n * onFocus={handleFocus}\n * onBlur={handleBlur}\n * >\n * {tags.map((tag, index) => (\n * <div key={tag.id} className={isFocused(index) ? \"focused\" : \"\"}>\n * {tag.label}\n * </div>\n * ))}\n * </div>\n * );\n * }\n * ```\n */\nexport function useItemsKeyboardNavigation<T>({\n\titems,\n\tonEnter,\n\tonDelete,\n\tcycleNavigation = false\n}: {\n\t/** Массив элементов для навигации */\n\titems: T[];\n\t/** Функция, вызываемая при нажатии Enter на элементе */\n\tonEnter?: (item: T, index: number) => void;\n\t/** Функция, вызываемая при нажатии Delete/Backspace на элементе */\n\tonDelete?: (item: T, index: number) => void;\n\t/** Включает циклическую навигацию (с последнего элемента на первый и наоборот) */\n\tcycleNavigation?: boolean;\n}) {\n\t/** Индекс текущего элемента с фокусом */\n\tconst [focusedIndex, setFocusedIndex] = useState<number | null>(null);\n\n\t/**\n\t * Следим за изменениями в items и корректируем focusedIndex при необходимости\n\t */\n\tuseEffect(() => {\n\t\tif (focusedIndex !== null && items.length > 0) {\n\t\t\t// Если текущий индекс выходит за границы массива\n\t\t\tif (focusedIndex >= items.length) {\n\t\t\t\t// Устанавливаем индекс на последний элемент\n\t\t\t\tsetFocusedIndex(items.length - 1);\n\t\t\t}\n\t\t} else if (items.length === 0) {\n\t\t\t// Если элементов нет, сбрасываем фокус\n\t\t\tsetFocusedIndex(null);\n\t\t} else if (focusedIndex === null && items.length > 0) {\n\t\t\tsetFocusedIndex(0);\n\t\t}\n\t}, [items, focusedIndex]);\n\n\t/**\n\t * Обработчик нажатия клавиш для навигации по элементам\n\t */\n\tconst handleKeyDown = useCallback(\n\t\t(e: KeyboardEvent<HTMLElement>) => {\n\t\t\t// Проверяем, есть ли элементы для навигации\n\t\t\tif (!items.length) return;\n\n\t\t\tswitch (e.key) {\n\t\t\t\tcase \"ArrowLeft\":\n\t\t\t\t\te.preventDefault();\n\t\t\t\t\tsetFocusedIndex((prev) => {\n\t\t\t\t\t\tif (prev === null) return 0;\n\t\t\t\t\t\tif (prev > 0) return prev - 1;\n\t\t\t\t\t\treturn cycleNavigation ? items.length - 1 : prev;\n\t\t\t\t\t});\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase \"ArrowRight\":\n\t\t\t\t\te.preventDefault();\n\t\t\t\t\tsetFocusedIndex((prev) => {\n\t\t\t\t\t\tif (prev === null) return 0;\n\t\t\t\t\t\tif (prev < items.length - 1) return prev + 1;\n\t\t\t\t\t\treturn cycleNavigation ? 0 : prev;\n\t\t\t\t\t});\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase \"Home\":\n\t\t\t\t\te.preventDefault();\n\t\t\t\t\tsetFocusedIndex(0);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase \"End\":\n\t\t\t\t\te.preventDefault();\n\t\t\t\t\tsetFocusedIndex(items.length - 1);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase \"Enter\":\n\t\t\t\t\tif (focusedIndex !== null && items[focusedIndex] && onEnter) {\n\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t\tonEnter(items[focusedIndex], focusedIndex);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase \"Delete\":\n\t\t\t\tcase \"Backspace\":\n\t\t\t\t\tif (focusedIndex !== null && items[focusedIndex] && onDelete) {\n\t\t\t\t\t\te.preventDefault();\n\n\t\t\t\t\t\t// Сохраняем текущий индекс перед удалением\n\t\t\t\t\t\tconst currentIndex = focusedIndex;\n\n\t\t\t\t\t\tonDelete(items[focusedIndex], focusedIndex);\n\n\t\t\t\t\t\t// Корректируем индекс после удаления\n\t\t\t\t\t\t// Это сработает корректно, если items обновится синхронно\n\t\t\t\t\t\t// В противном случае, корректировку нужно делать в эффекте\n\t\t\t\t\t\tif (currentIndex >= items.length - 1) {\n\t\t\t\t\t\t\tsetFocusedIndex(Math.max(0, items.length - 2));\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\n\t\t\t\tdefault:\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t},\n\t\t[items, focusedIndex, onEnter, onDelete, cycleNavigation]\n\t);\n\n\t/**\n\t * Обработчик получения фокуса контейнером\n\t */\n\tconst handleFocus = useCallback(() => {\n\t\tif (items.length) {\n\t\t\tsetFocusedIndex(0);\n\t\t}\n\t}, [items]);\n\n\t/**\n\t * Обработчик потери фокуса контейнером\n\t */\n\tconst handleBlur = useCallback(() => {\n\t\tsetFocusedIndex(null);\n\t}, []);\n\n\t/**\n\t * Проверяет, находится ли элемент с указанным индексом в фокусе\n\t */\n\tconst isFocused = useCallback((index: number) => focusedIndex === index, [focusedIndex]);\n\n\t/**\n\t * Безопасно устанавливает фокус на элемент по индексу\n\t * @param index Индекс элемента для фокусировки\n\t * @returns Возвращает true, если индекс был установлен успешно\n\t */\n\tconst focusItemAtIndex = useCallback(\n\t\t(index: number) => {\n\t\t\tif (index >= 0 && index < items.length) {\n\t\t\t\tsetFocusedIndex(index);\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn false;\n\t\t},\n\t\t[items.length]\n\t);\n\n\treturn {\n\t\tfocusedIndex,\n\t\thandleKeyDown,\n\t\thandleFocus,\n\t\thandleBlur,\n\t\tisFocused,\n\t\tfocusItemAtIndex\n\t};\n}\n","import { TagButton, TagClose, TagDivider, TagWrapper } from \"@/components/tag/Tag\";\nimport { useIsMobile } from \"@/hooks/useBreakpoints\";\nimport { PropsWithChildren, useMemo } from \"react\";\nimport { tv } from \"tailwind-variants\";\n\nconst searchSelectTagStyles = tv({\n\tbase: \"rounded-sm\",\n\tvariants: {\n\t\tselected: {\n\t\t\ttrue: \"group-focus-within/search-select-trigger:shadow-focus\"\n\t\t}\n\t}\n});\n\nexport interface SearchSelectTagProps {\n\tonLabelClick: (e: React.MouseEvent<HTMLElement>) => void;\n\tonClose: (e: React.MouseEvent<HTMLElement>) => void;\n\treadonly?: boolean;\n\tisFocused?: boolean;\n}\n\nexport const SearchSelectTag = (props: PropsWithChildren<SearchSelectTagProps>) => {\n\tconst { children, onLabelClick, onClose, readonly = false, isFocused: selected = false } = props;\n\tconst hasClose = Boolean(onClose);\n\tconst isMobile = useIsMobile();\n\tconst size = useMemo(() => (isMobile ? \"lg\" : \"md\"), [isMobile]);\n\tconst styles = searchSelectTagStyles({ selected });\n\n\treturn (\n\t\t<TagWrapper size={size} className={styles}>\n\t\t\t<TagButton position={hasClose && !readonly ? \"left\" : undefined} size={size} onClick={onLabelClick} asChild>\n\t\t\t\t<span>{children}</span>\n\t\t\t</TagButton>\n\n\t\t\t{!readonly && (\n\t\t\t\t<>\n\t\t\t\t\t<TagDivider />\n\t\t\t\t\t<TagClose size={size} onClick={onClose} tag=\"span\" />\n\t\t\t\t</>\n\t\t\t)}\n\t\t</TagWrapper>\n\t);\n};\n\nSearchSelectTag.displayName = \"SearchSelectTag\";\n"],"names":["useControllableState","value","defaultValue","onChange","uncontrolledValue","setUncontrolledValue","useState","isControlled","actualValue","setValue","useCallback","nextValue","resolvedValue","useItemsKeyboardNavigation","items","onEnter","onDelete","cycleNavigation","focusedIndex","setFocusedIndex","useEffect","handleKeyDown","e","prev","currentIndex","handleFocus","handleBlur","isFocused","index","focusItemAtIndex","searchSelectTagStyles","tv","SearchSelectTag","props","children","onLabelClick","onClose","readonly","selected","hasClose","isMobile","useIsMobile","size","useMemo","styles","jsxs","TagWrapper","jsx","TagButton","Fragment","TagDivider","TagClose"],"mappings":";;;;;AAcO,SAASA,EAAwB,EAAE,OAAAC,GAAO,cAAAC,GAAc,UAAAC,KAA2C;AACzG,QAAM,CAACC,GAAmBC,CAAoB,IAAIC,EAASJ,CAAY,GAEjEK,IAAeN,MAAU,QACzBO,IAAcD,IAAeN,IAAQG,GAErCK,IAAWC;AAAA,IAChB,CAACC,MAAyC;AACzC,YAAMC,IACL,OAAOD,KAAc,aAAcA,EAAkCH,CAAgB,IAAIG;AAE1F,MAAKJ,KACJF,EAAqBO,CAAa,GAGnCT,IAAWS,CAAa;AAAA,IACzB;AAAA,IACA,CAACJ,GAAaD,GAAcJ,CAAQ;AAAA,EACrC;AAEO,SAAA,CAACK,GAAaC,CAAQ;AAC9B;ACKO,SAASI,EAA8B;AAAA,EAC7C,OAAAC;AAAA,EACA,SAAAC;AAAA,EACA,UAAAC;AAAA,EACA,iBAAAC,IAAkB;AACnB,GASG;AAEF,QAAM,CAACC,GAAcC,CAAe,IAAIb,EAAwB,IAAI;AAKpE,EAAAc,EAAU,MAA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AS,CAAA,GACjB;AAAA,IAEC,CAACG,KAEA,gBAAAQ,EAAAI,GAAA,EAAA,UAAA;AAAA,MAAA,gBAAAF,EAACG,GAAW,EAAA;AAAA,wBACXC,GAAS,EAAA,MAAAT,GAAY,SAASN,GAAS,KAAI,OAAO,CAAA;AAAA,IAAA,EACpD,CAAA;AAAA,EAAA,GAEF;AAEF;AAEAJ,EAAgB,cAAc;"}
|
|
1
|
+
{"version":3,"file":"SearchSelectTag-Ce-Q9JGR.js","sources":["../src/hooks/useControllableState.ts","../src/hooks/useItemsKeyboardNavigation.ts","../src/components/search-select/components/SearchSelectTag.tsx"],"sourcesContent":["import { useCallback, useState } from \"react\";\n\ntype UseControllableStateParams<T> = {\n\t/** Controlled значение */\n\tvalue?: T;\n\t/** Значение по умолчанию для uncontrolled режима */\n\tdefaultValue?: T;\n\t/** Callback при изменении значения */\n\tonChange?: (value: T) => void;\n};\n\n/**\n * Универсальный хук для управления controlled/uncontrolled состоянием.\n */\nexport function useControllableState<T>({ value, defaultValue, onChange }: UseControllableStateParams<T>) {\n\tconst [uncontrolledValue, setUncontrolledValue] = useState(defaultValue);\n\n\tconst isControlled = value !== undefined;\n\tconst actualValue = isControlled ? value : uncontrolledValue;\n\n\tconst setValue = useCallback(\n\t\t(nextValue: T | ((prevValue: T) => T)) => {\n\t\t\tconst resolvedValue =\n\t\t\t\ttypeof nextValue === \"function\" ? (nextValue as (prevValue: T) => T)(actualValue as T) : nextValue;\n\n\t\t\tif (!isControlled) {\n\t\t\t\tsetUncontrolledValue(resolvedValue);\n\t\t\t}\n\n\t\t\tonChange?.(resolvedValue);\n\t\t},\n\t\t[actualValue, isControlled, onChange]\n\t);\n\n\treturn [actualValue, setValue] as const;\n}\n","import { useCallback, useState, KeyboardEvent, useEffect } from \"react\";\n\n/**\n * Хук для навигации по элементам с помощью клавиатуры\n *\n * @example\n * ```tsx\n * function TagList({ tags, onTagSelect, onTagDelete }) {\n * const containerRef = useRef(null);\n *\n * const {\n * focusedIndex,\n * handleKeyDown,\n * handleFocus,\n * handleBlur,\n * isFocused\n * } = useItemsKeyboardNavigation({\n * items: tags,\n * onEnter: onTagSelect,\n * onDelete: onTagDelete\n * });\n *\n * return (\n * <div\n * ref={containerRef}\n * tabIndex={0}\n * onKeyDown={handleKeyDown}\n * onFocus={handleFocus}\n * onBlur={handleBlur}\n * >\n * {tags.map((tag, index) => (\n * <div key={tag.id} className={isFocused(index) ? \"focused\" : \"\"}>\n * {tag.label}\n * </div>\n * ))}\n * </div>\n * );\n * }\n * ```\n */\nexport function useItemsKeyboardNavigation<T>({\n\titems,\n\tonEnter,\n\tonDelete,\n\tcycleNavigation = false\n}: {\n\t/** Массив элементов для навигации */\n\titems: T[];\n\t/** Функция, вызываемая при нажатии Enter на элементе */\n\tonEnter?: (item: T, index: number) => void;\n\t/** Функция, вызываемая при нажатии Delete/Backspace на элементе */\n\tonDelete?: (item: T, index: number) => void;\n\t/** Включает циклическую навигацию (с последнего элемента на первый и наоборот) */\n\tcycleNavigation?: boolean;\n}) {\n\t/** Индекс текущего элемента с фокусом */\n\tconst [focusedIndex, setFocusedIndex] = useState<number | null>(null);\n\n\t/**\n\t * Следим за изменениями в items и корректируем focusedIndex при необходимости\n\t */\n\tuseEffect(() => {\n\t\tif (focusedIndex !== null && items.length > 0) {\n\t\t\t// Если текущий индекс выходит за границы массива\n\t\t\tif (focusedIndex >= items.length) {\n\t\t\t\t// Устанавливаем индекс на последний элемент\n\t\t\t\tsetFocusedIndex(items.length - 1);\n\t\t\t}\n\t\t} else if (items.length === 0) {\n\t\t\t// Если элементов нет, сбрасываем фокус\n\t\t\tsetFocusedIndex(null);\n\t\t} else if (focusedIndex === null && items.length > 0) {\n\t\t\tsetFocusedIndex(0);\n\t\t}\n\t}, [items, focusedIndex]);\n\n\t/**\n\t * Обработчик нажатия клавиш для навигации по элементам\n\t */\n\tconst handleKeyDown = useCallback(\n\t\t(e: KeyboardEvent<HTMLElement>) => {\n\t\t\t// Проверяем, есть ли элементы для навигации\n\t\t\tif (!items.length) return;\n\n\t\t\tswitch (e.key) {\n\t\t\t\tcase \"ArrowLeft\":\n\t\t\t\t\te.preventDefault();\n\t\t\t\t\tsetFocusedIndex((prev) => {\n\t\t\t\t\t\tif (prev === null) return 0;\n\t\t\t\t\t\tif (prev > 0) return prev - 1;\n\t\t\t\t\t\treturn cycleNavigation ? items.length - 1 : prev;\n\t\t\t\t\t});\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase \"ArrowRight\":\n\t\t\t\t\te.preventDefault();\n\t\t\t\t\tsetFocusedIndex((prev) => {\n\t\t\t\t\t\tif (prev === null) return 0;\n\t\t\t\t\t\tif (prev < items.length - 1) return prev + 1;\n\t\t\t\t\t\treturn cycleNavigation ? 0 : prev;\n\t\t\t\t\t});\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase \"Home\":\n\t\t\t\t\te.preventDefault();\n\t\t\t\t\tsetFocusedIndex(0);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase \"End\":\n\t\t\t\t\te.preventDefault();\n\t\t\t\t\tsetFocusedIndex(items.length - 1);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase \"Enter\":\n\t\t\t\t\tif (focusedIndex !== null && items[focusedIndex] && onEnter) {\n\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t\tonEnter(items[focusedIndex], focusedIndex);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase \"Delete\":\n\t\t\t\tcase \"Backspace\":\n\t\t\t\t\tif (focusedIndex !== null && items[focusedIndex] && onDelete) {\n\t\t\t\t\t\te.preventDefault();\n\n\t\t\t\t\t\t// Сохраняем текущий индекс перед удалением\n\t\t\t\t\t\tconst currentIndex = focusedIndex;\n\n\t\t\t\t\t\tonDelete(items[focusedIndex], focusedIndex);\n\n\t\t\t\t\t\t// Корректируем индекс после удаления\n\t\t\t\t\t\t// Это сработает корректно, если items обновится синхронно\n\t\t\t\t\t\t// В противном случае, корректировку нужно делать в эффекте\n\t\t\t\t\t\tif (currentIndex >= items.length - 1) {\n\t\t\t\t\t\t\tsetFocusedIndex(Math.max(0, items.length - 2));\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\n\t\t\t\tdefault:\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t},\n\t\t[items, focusedIndex, onEnter, onDelete, cycleNavigation]\n\t);\n\n\t/**\n\t * Обработчик получения фокуса контейнером\n\t */\n\tconst handleFocus = useCallback(() => {\n\t\tif (items.length) {\n\t\t\tsetFocusedIndex(0);\n\t\t}\n\t}, [items]);\n\n\t/**\n\t * Обработчик потери фокуса контейнером\n\t */\n\tconst handleBlur = useCallback(() => {\n\t\tsetFocusedIndex(null);\n\t}, []);\n\n\t/**\n\t * Проверяет, находится ли элемент с указанным индексом в фокусе\n\t */\n\tconst isFocused = useCallback((index: number) => focusedIndex === index, [focusedIndex]);\n\n\t/**\n\t * Безопасно устанавливает фокус на элемент по индексу\n\t * @param index Индекс элемента для фокусировки\n\t * @returns Возвращает true, если индекс был установлен успешно\n\t */\n\tconst focusItemAtIndex = useCallback(\n\t\t(index: number) => {\n\t\t\tif (index >= 0 && index < items.length) {\n\t\t\t\tsetFocusedIndex(index);\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn false;\n\t\t},\n\t\t[items.length]\n\t);\n\n\treturn {\n\t\tfocusedIndex,\n\t\thandleKeyDown,\n\t\thandleFocus,\n\t\thandleBlur,\n\t\tisFocused,\n\t\tfocusItemAtIndex\n\t};\n}\n","import { TagButton, TagClose, TagDivider, TagWrapper } from \"@/components/tag/Tag\";\nimport { useIsMobile } from \"@/hooks/useBreakpoints\";\nimport { PropsWithChildren, useMemo } from \"react\";\nimport { tv } from \"tailwind-variants\";\n\nconst searchSelectTagStyles = tv({\n\tbase: \"rounded-sm\",\n\tvariants: {\n\t\tselected: {\n\t\t\ttrue: \"group-focus-within/search-select-trigger:shadow-focus\"\n\t\t}\n\t}\n});\n\nexport interface SearchSelectTagProps {\n\tonLabelClick: (e: React.MouseEvent<HTMLElement>) => void;\n\tonClose: (e: React.MouseEvent<HTMLElement>) => void;\n\treadonly?: boolean;\n\tisFocused?: boolean;\n}\n\nexport const SearchSelectTag = (props: PropsWithChildren<SearchSelectTagProps>) => {\n\tconst { children, onLabelClick, onClose, readonly = false, isFocused: selected = false } = props;\n\tconst hasClose = Boolean(onClose);\n\tconst isMobile = useIsMobile();\n\tconst size = useMemo(() => (isMobile ? \"lg\" : \"md\"), [isMobile]);\n\tconst styles = searchSelectTagStyles({ selected });\n\n\treturn (\n\t\t<TagWrapper size={size} className={styles}>\n\t\t\t<TagButton position={hasClose && !readonly ? \"left\" : undefined} size={size} onClick={onLabelClick} asChild>\n\t\t\t\t<span>{children}</span>\n\t\t\t</TagButton>\n\n\t\t\t{!readonly && (\n\t\t\t\t<>\n\t\t\t\t\t<TagDivider />\n\t\t\t\t\t<TagClose size={size} onClick={onClose} tag=\"span\" />\n\t\t\t\t</>\n\t\t\t)}\n\t\t</TagWrapper>\n\t);\n};\n\nSearchSelectTag.displayName = \"SearchSelectTag\";\n"],"names":["useControllableState","value","defaultValue","onChange","uncontrolledValue","setUncontrolledValue","useState","isControlled","actualValue","setValue","useCallback","nextValue","resolvedValue","useItemsKeyboardNavigation","items","onEnter","onDelete","cycleNavigation","focusedIndex","setFocusedIndex","useEffect","handleKeyDown","e","prev","currentIndex","handleFocus","handleBlur","isFocused","index","focusItemAtIndex","searchSelectTagStyles","tv","SearchSelectTag","props","children","onLabelClick","onClose","readonly","selected","hasClose","isMobile","useIsMobile","size","useMemo","styles","jsxs","TagWrapper","jsx","TagButton","Fragment","TagDivider","TagClose"],"mappings":";;;;;AAcO,SAASA,EAAwB,EAAE,OAAAC,GAAO,cAAAC,GAAc,UAAAC,KAA2C;AACzG,QAAM,CAACC,GAAmBC,CAAoB,IAAIC,EAASJ,CAAY,GAEjEK,IAAeN,MAAU,QACzBO,IAAcD,IAAeN,IAAQG,GAErCK,IAAWC;AAA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