@zayne-labs/ui-react 0.6.3 → 0.7.1
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/esm/{chunk-ENDWJXPF.js → chunk-L2SROZYQ.js} +2 -2
- package/dist/esm/{chunk-ENDWJXPF.js.map → chunk-L2SROZYQ.js.map} +1 -1
- package/dist/esm/common/await/index.js +37 -3
- package/dist/esm/common/await/index.js.map +1 -1
- package/dist/esm/common/show/index.d.ts +1 -1
- package/dist/esm/common/show/index.js +48 -2
- package/dist/esm/common/show/index.js.map +1 -1
- package/dist/esm/common/slot/index.js +1 -1
- package/dist/esm/common/suspense-with-boundary/index.js +11 -2
- package/dist/esm/common/suspense-with-boundary/index.js.map +1 -1
- package/dist/esm/common/switch/index.js +38 -2
- package/dist/esm/common/switch/index.js.map +1 -1
- package/dist/esm/common/teleport/index.js +28 -1
- package/dist/esm/common/teleport/index.js.map +1 -1
- package/dist/esm/ui/card/index.js +43 -4
- package/dist/esm/ui/card/index.js.map +1 -1
- package/dist/esm/ui/carousel/index.js +272 -4
- package/dist/esm/ui/carousel/index.js.map +1 -1
- package/dist/esm/ui/drag-scroll/index.js +117 -2
- package/dist/esm/ui/drag-scroll/index.js.map +1 -1
- package/dist/esm/ui/drop-zone/index.js +137 -2
- package/dist/esm/ui/drop-zone/index.js.map +1 -1
- package/dist/esm/ui/form/index.js +508 -12
- package/dist/esm/ui/form/index.js.map +1 -1
- package/package.json +6 -9
- package/dist/esm/chunk-CB2EZJYW.js +0 -31
- package/dist/esm/chunk-CB2EZJYW.js.map +0 -1
- package/dist/esm/chunk-CWUEUCR5.js +0 -3
- package/dist/esm/chunk-CWUEUCR5.js.map +0 -1
- package/dist/esm/chunk-E42DOTGX.js +0 -119
- package/dist/esm/chunk-E42DOTGX.js.map +0 -1
- package/dist/esm/chunk-EOI2VNGP.js +0 -39
- package/dist/esm/chunk-EOI2VNGP.js.map +0 -1
- package/dist/esm/chunk-FPCKBOJN.js +0 -50
- package/dist/esm/chunk-FPCKBOJN.js.map +0 -1
- package/dist/esm/chunk-GVL6BLX5.js +0 -274
- package/dist/esm/chunk-GVL6BLX5.js.map +0 -1
- package/dist/esm/chunk-IJUYDZCZ.js +0 -510
- package/dist/esm/chunk-IJUYDZCZ.js.map +0 -1
- package/dist/esm/chunk-NPIJ4XZP.js +0 -13
- package/dist/esm/chunk-NPIJ4XZP.js.map +0 -1
- package/dist/esm/chunk-PNYEIX7F.js +0 -3
- package/dist/esm/chunk-PNYEIX7F.js.map +0 -1
- package/dist/esm/chunk-PXYYL2LL.js +0 -45
- package/dist/esm/chunk-PXYYL2LL.js.map +0 -1
- package/dist/esm/chunk-RQZL6ZG6.js +0 -139
- package/dist/esm/chunk-RQZL6ZG6.js.map +0 -1
- package/dist/esm/chunk-SVQ4WBSO.js +0 -40
- package/dist/esm/chunk-SVQ4WBSO.js.map +0 -1
- package/dist/esm/common/index.d.ts +0 -12
- package/dist/esm/common/index.js +0 -12
- package/dist/esm/common/index.js.map +0 -1
- package/dist/esm/index.d.ts +0 -20
- package/dist/esm/index.js +0 -19
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/ui/index.d.ts +0 -11
- package/dist/esm/ui/index.js +0 -19
- package/dist/esm/ui/index.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/icons/ChevronLeftIcon.tsx","../../src/components/ui/carousel/carousel-store-context.tsx","../../src/components/ui/carousel/useCarouselOptions.ts","../../src/components/ui/carousel/carousel.tsx","../../src/components/ui/carousel/carousel-parts.ts"],"names":["React","React2"],"mappings":";;;;;;;;;AAEA,IAAM,kBAAkB,CAAC,KAAA,0CACvB,KAAI,EAAA,EAAA,KAAA,EAAM,8BAA6B,KAAM,EAAA,KAAA,EAAM,MAAO,EAAA,KAAA,EAAM,SAAQ,WAAa,EAAA,GAAG,yBACvFA,MAAA,CAAA,aAAA,CAAA,GAAA,EAAA,EAAE,MAAK,MAAO,EAAA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;AAAA,QACA,UAAY,EAAA,MAAA;AAAA,QACZ,YAAiB,KAAA,YAAA,IAAgB,CAAC,iBAAA,EAAmB,YAAY,SAAS;AAAA;AAC3E;AAAA,GAEF,CAAA;AAEF;;;AC7OA,IAAA,sBAAA,GAAA;AAAA,QAAA,CAAA,sBAAA,EAAA;AAAA,EAAA,MAAA,EAAA,MAAA,cAAA;AAAA,EAAA,OAAA,EAAA,MAAA,eAAA;AAAA,EAAA,OAAA,EAAA,MAAA,eAAA;AAAA,EAAA,QAAA,EAAA,MAAA,gBAAA;AAAA,EAAA,SAAA,EAAA,MAAA,iBAAA;AAAA,EAAA,gBAAA,EAAA,MAAA,sBAAA;AAAA,EAAA,IAAA,EAAA,MAAA,YAAA;AAAA,EAAA,WAAA,EAAA,MAAA,iBAAA;AAAA,EAAA,IAAA,EAAA,MAAA;AAAA,CAAA,CAAA","file":"chunk-GVL6BLX5.js","sourcesContent":["import * as React from \"react\";\n\nconst ChevronLeftIcon = (props: React.SVGProps<SVGSVGElement>) => (\n\t<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"1em\" height=\"1em\" viewBox=\"0 0 24 24\" {...props}>\n\t\t<g fill=\"none\" stroke=\"currentColor\" strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth=\"2\">\n\t\t\t<circle cx=\"12\" cy=\"12\" r=\"10\" />\n\t\t\t<path d=\"m14 16l-4-4l4-4\" />\n\t\t</g>\n\t</svg>\n);\n\nexport { ChevronLeftIcon };\n","import * as React from \"react\";\n\nimport { useConstant } from \"@zayne-labs/toolkit-react\";\nimport { createZustandContext } from \"@zayne-labs/toolkit-react/zustand\";\nimport type { PrettyOmit } from \"@zayne-labs/toolkit-type-helpers\";\nimport { useEffect } from \"react\";\nimport { create } from \"zustand\";\nimport type { CarouselProviderProps, CarouselStore, ImagesType } from \"./types\";\n\nconst [Provider, useCarouselStoreContext] = createZustandContext<CarouselStore>({\n\thookName: \"useCarouselStore\",\n\tname: \"CarouselStoreContext\",\n\tproviderName: \"CarouselContextProvider\",\n});\n\n// CarouselStore Creation\nconst createCarouselStore = <TImages extends ImagesType>(\n\tstoreValues: PrettyOmit<CarouselProviderProps<TImages>, \"children\">\n) => {\n\tconst { images, onSlideBtnClick } = storeValues;\n\n\tconst useInitCarouselStore = create<CarouselStore<TImages>>()((set, get) => ({\n\t\tcurrentSlide: 0,\n\t\timages,\n\t\tmaxSlide: images.length - 1,\n\n\t\t/* eslint-disable perfectionist/sort-objects -- actions should be last */\n\t\tactions: {\n\t\t\t/* eslint-enable perfectionist/sort-objects -- actions should be last */\n\n\t\t\tgoToNextSlide: () => {\n\t\t\t\tconst { currentSlide, maxSlide } = get();\n\t\t\t\tconst { goToSlide } = get().actions;\n\n\t\t\t\tif (currentSlide === maxSlide) {\n\t\t\t\t\tgoToSlide(0);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tgoToSlide(currentSlide + 1);\n\t\t\t},\n\n\t\t\tgoToPreviousSlide: () => {\n\t\t\t\tconst { currentSlide, maxSlide } = get();\n\t\t\t\tconst { goToSlide } = get().actions;\n\n\t\t\t\tif (currentSlide === 0) {\n\t\t\t\t\tgoToSlide(maxSlide);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tgoToSlide(currentSlide - 1);\n\t\t\t},\n\n\t\t\tgoToSlide: (newValue) => {\n\t\t\t\tonSlideBtnClick?.();\n\n\t\t\t\tset({ currentSlide: newValue });\n\t\t\t},\n\t\t},\n\t}));\n\n\treturn useInitCarouselStore;\n};\n\nconst useCarousel = <TImages extends ImagesType>(\n\tprops: Omit<CarouselProviderProps<TImages>, \"children\">\n) => {\n\tconst { images, onSlideBtnClick } = props;\n\n\tconst useInitCarouselStore = useConstant(() => createCarouselStore({ images, onSlideBtnClick }));\n\n\t// == To set images again when a page is mounted, preventing stale images from previous page\n\tuseEffect(() => {\n\t\tuseInitCarouselStore.setState({ images });\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps -- useInitCarouselStore is stable\n\t}, [images]);\n\n\treturn useInitCarouselStore;\n};\n\n// == Provider Component\nfunction CarouselContextProvider<TImages extends ImagesType>(props: CarouselProviderProps<TImages>) {\n\tconst { children, images, onSlideBtnClick } = props;\n\n\tconst useInitCarouselStore = useCarousel({ images, onSlideBtnClick });\n\n\treturn <Provider value={useInitCarouselStore}>{children}</Provider>;\n}\n\n// eslint-disable-next-line react-refresh/only-export-components -- It's fine\nexport { useCarouselStoreContext, CarouselContextProvider };\n","import { useAnimationInterval, useCallbackRef } from \"@zayne-labs/toolkit-react\";\nimport { useState } from \"react\";\nimport { useCarouselStoreContext } from \"./carousel-store-context\";\n\ntype CarouselOptions = {\n\tautoSlideInterval?: number;\n\thasAutoSlide?: boolean;\n\tshouldPauseOnHover?: boolean;\n};\n\nconst useCarouselOptions = (options: CarouselOptions = {}) => {\n\tconst { autoSlideInterval = 5000, hasAutoSlide = false, shouldPauseOnHover = false } = options;\n\n\tconst { goToNextSlide } = useCarouselStoreContext((state) => state.actions);\n\n\tconst [isPaused, setIsPaused] = useState(false);\n\n\tconst shouldAutoSlide = hasAutoSlide && !isPaused;\n\n\tuseAnimationInterval({\n\t\tintervalDuration: shouldAutoSlide ? autoSlideInterval : null,\n\t\tonAnimation: goToNextSlide,\n\t});\n\n\tconst pauseAutoSlide = useCallbackRef(() => shouldPauseOnHover && setIsPaused(true));\n\n\tconst resumeAutoSlide = useCallbackRef(() => shouldPauseOnHover && setIsPaused(false));\n\n\treturn { pauseAutoSlide, resumeAutoSlide };\n};\n\nexport { useCarouselOptions };\n","\"use client\";\n\nimport * as React from \"react\";\n\nimport { getElementList } from \"@/components/common/for\";\nimport { ChevronLeftIcon } from \"@/components/icons\";\nimport { cnMerge } from \"@/lib/utils/cn\";\nimport type { MyCustomCss, PolymorphicProps } from \"@zayne-labs/toolkit-react/utils\";\nimport { useCarouselStoreContext } from \"./carousel-store-context\";\nimport type {\n\tCarouselButtonsProps,\n\tCarouselContentProps,\n\tCarouselControlProps,\n\tCarouselIndicatorProps,\n\tCarouselWrapperProps,\n\tOtherCarouselProps,\n} from \"./types\";\nimport { useCarouselOptions } from \"./useCarouselOptions\";\n\n// TODO - Add dragging and swiping support\nexport function CarouselContent<TElement extends React.ElementType = \"article\">(\n\tprops: PolymorphicProps<TElement, CarouselContentProps>\n) {\n\tconst {\n\t\tas: HtmlElement = \"article\",\n\t\tautoSlideInterval,\n\t\tchildren,\n\t\tclassNames,\n\t\thasAutoSlide,\n\t\tshouldPauseOnHover,\n\t} = props;\n\n\tconst { pauseAutoSlide, resumeAutoSlide } = useCarouselOptions({\n\t\tautoSlideInterval,\n\t\thasAutoSlide,\n\t\tshouldPauseOnHover,\n\t});\n\n\t// FIXME - Prevent touch swipe on mobile using a cover element or allow swipe but it must update the state appriopriately\n\treturn (\n\t\t<HtmlElement\n\t\t\tdata-id=\"Carousel\"\n\t\t\tclassName={cnMerge(\"relative select-none\", classNames?.base)}\n\t\t\tonMouseEnter={pauseAutoSlide}\n\t\t\tonMouseLeave={resumeAutoSlide}\n\t\t>\n\t\t\t<div\n\t\t\t\tdata-id=\"Scroll Container\"\n\t\t\t\tclassName={cnMerge(\n\t\t\t\t\t\"flex size-full overflow-x-scroll [scrollbar-width:none] [&::-webkit-scrollbar]:hidden\",\n\t\t\t\t\tclassNames?.scrollContainer\n\t\t\t\t)}\n\t\t\t>\n\t\t\t\t{children}\n\t\t\t</div>\n\t\t</HtmlElement>\n\t);\n}\n\nexport function CarouselButton(props: CarouselButtonsProps) {\n\tconst { classNames, icon, variant } = props;\n\n\tconst { goToNextSlide, goToPreviousSlide } = useCarouselStoreContext((state) => state.actions);\n\n\treturn (\n\t\t<button\n\t\t\ttype=\"button\"\n\t\t\tclassName={cnMerge(\n\t\t\t\t\"z-30 flex h-full w-[15%] items-center\",\n\t\t\t\tvariant === \"prev\" ? \"justify-start\" : \"justify-end\",\n\t\t\t\tclassNames?.base\n\t\t\t)}\n\t\t\tonClick={variant === \"prev\" ? goToPreviousSlide : goToNextSlide}\n\t\t>\n\t\t\t<span className={cnMerge(\"transition-transform active:scale-[1.06]\", classNames?.iconContainer)}>\n\t\t\t\t{icon ?? (\n\t\t\t\t\t<ChevronLeftIcon\n\t\t\t\t\t\tclassName={cnMerge(variant === \"next\" && \"rotate-180\", classNames?.defaultIcon)}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t</span>\n\t\t</button>\n\t);\n}\n\nexport function CarouselControls(props: CarouselControlProps) {\n\tconst { classNames, icon } = props;\n\n\treturn (\n\t\t<div className={cnMerge(\"absolute inset-0 flex justify-between\", classNames?.base)}>\n\t\t\t{icon?.iconType ? (\n\t\t\t\t<>\n\t\t\t\t\t<CarouselButton\n\t\t\t\t\t\tvariant=\"prev\"\n\t\t\t\t\t\tclassNames={{\n\t\t\t\t\t\t\tdefaultIcon: classNames?.defaultIcon,\n\t\t\t\t\t\t\ticonContainer: cnMerge(\n\t\t\t\t\t\t\t\ticon.iconType === \"nextIcon\" && \"rotate-180\",\n\t\t\t\t\t\t\t\tclassNames?.iconContainer\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t}}\n\t\t\t\t\t\ticon={icon.icon}\n\t\t\t\t\t/>\n\t\t\t\t\t<CarouselButton\n\t\t\t\t\t\tvariant=\"next\"\n\t\t\t\t\t\tclassNames={{\n\t\t\t\t\t\t\tdefaultIcon: classNames?.defaultIcon,\n\t\t\t\t\t\t\ticonContainer: cnMerge(\n\t\t\t\t\t\t\t\ticon.iconType === \"prevIcon\" && \"rotate-180\",\n\t\t\t\t\t\t\t\tclassNames?.iconContainer\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t}}\n\t\t\t\t\t\ticon={icon.icon}\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t) : (\n\t\t\t\t<>\n\t\t\t\t\t<CarouselButton\n\t\t\t\t\t\tvariant=\"prev\"\n\t\t\t\t\t\tclassNames={{\n\t\t\t\t\t\t\tdefaultIcon: classNames?.defaultIcon,\n\t\t\t\t\t\t\ticonContainer: classNames?.iconContainer,\n\t\t\t\t\t\t}}\n\t\t\t\t\t\ticon={icon?.prev}\n\t\t\t\t\t/>\n\t\t\t\t\t<CarouselButton\n\t\t\t\t\t\tvariant=\"next\"\n\t\t\t\t\t\tclassNames={{\n\t\t\t\t\t\t\tdefaultIcon: classNames?.defaultIcon,\n\t\t\t\t\t\t\ticonContainer: classNames?.iconContainer,\n\t\t\t\t\t\t}}\n\t\t\t\t\t\ticon={icon?.next}\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t)}\n\t\t</div>\n\t);\n}\n\nexport function CarouselItemGroup<TArrayItem>(props: CarouselWrapperProps<TArrayItem>) {\n\tconst { children, className, each, render } = props;\n\n\tconst [ItemList] = getElementList(\"base\");\n\tconst currentSlide = useCarouselStoreContext((state) => state.currentSlide);\n\tconst images = useCarouselStoreContext((state) => each ?? (state.images as TArrayItem[]));\n\n\treturn (\n\t\t<ul\n\t\t\tdata-id=\"Carousel Image Wrapper\"\n\t\t\tclassName={cnMerge(\n\t\t\t\t`flex w-full shrink-0 [transform:translate3d(var(--translate-distance),0,0)] snap-center\n\t\t\t\t[transition:transform_800ms_ease]`,\n\t\t\t\tclassName\n\t\t\t)}\n\t\t\tstyle={\n\t\t\t\t{\n\t\t\t\t\t\"--translate-distance\": `-${currentSlide * 100}%`,\n\t\t\t\t} satisfies MyCustomCss as MyCustomCss\n\t\t\t}\n\t\t>\n\t\t\t{typeof render === \"function\" ? (\n\t\t\t\t<ItemList each={images} render={render} />\n\t\t\t) : (\n\t\t\t\t<ItemList each={images}>{children}</ItemList>\n\t\t\t)}\n\t\t</ul>\n\t);\n}\n\nexport function CarouselItem({ children, className, ...restOfProps }: OtherCarouselProps) {\n\treturn (\n\t\t<li\n\t\t\tclassName={cnMerge(\"flex w-full shrink-0 snap-center justify-center\", className)}\n\t\t\t{...restOfProps}\n\t\t>\n\t\t\t{children}\n\t\t</li>\n\t);\n}\n\nexport function CarouselCaption<TElement extends React.ElementType = \"div\">(\n\tprops: PolymorphicProps<TElement, OtherCarouselProps>\n) {\n\tconst { as: HtmlElement = \"div\", children, className } = props;\n\n\treturn (\n\t\t<HtmlElement data-id=\"Carousel Caption\" className={cnMerge(\"absolute z-10\", className)}>\n\t\t\t{children}\n\t\t</HtmlElement>\n\t);\n}\n\nexport function CarouselIndicatorGroup<TArrayItem>(props: CarouselWrapperProps<TArrayItem>) {\n\tconst { children, className, each, render } = props;\n\n\tconst images = useCarouselStoreContext((state) => each ?? (state.images as TArrayItem[]));\n\tconst [IndicatorList] = getElementList(\"base\");\n\n\treturn (\n\t\t<ul\n\t\t\tdata-id=\"Carousel Indicators\"\n\t\t\tclassName={cnMerge(\n\t\t\t\t\"absolute bottom-10 z-[2] flex w-full items-center justify-center gap-6\",\n\t\t\t\tclassName\n\t\t\t)}\n\t\t>\n\t\t\t{typeof render === \"function\" ? (\n\t\t\t\t<IndicatorList each={images} render={render} />\n\t\t\t) : (\n\t\t\t\t<IndicatorList each={images}>{children}</IndicatorList>\n\t\t\t)}\n\t\t</ul>\n\t);\n}\n\nexport function CarouselIndicator(props: CarouselIndicatorProps) {\n\tconst { classNames, currentIndex } = props;\n\n\tconst {\n\t\tactions: { goToSlide },\n\t\tcurrentSlide,\n\t} = useCarouselStoreContext((state) => state);\n\n\treturn (\n\t\t<li className={cnMerge(\"inline-flex\", classNames?.base)}>\n\t\t\t<button\n\t\t\t\tdata-active={currentIndex === currentSlide}\n\t\t\t\ttype=\"button\"\n\t\t\t\tonClick={() => goToSlide(currentIndex)}\n\t\t\t\tclassName={cnMerge(\n\t\t\t\t\t\"size-[6px] rounded-[50%]\",\n\t\t\t\t\tclassNames?.button,\n\t\t\t\t\tcurrentIndex === currentSlide && [\"w-14 rounded-lg\", classNames?.activeBtn]\n\t\t\t\t)}\n\t\t\t/>\n\t\t</li>\n\t);\n}\n","export { CarouselContextProvider as Root } from \"./carousel-store-context\";\nexport {\n\tCarouselContent as Content,\n\tCarouselControls as Controls,\n\tCarouselButton as Button,\n\tCarouselItem as Item,\n\tCarouselItemGroup as ItemWrapper,\n\tCarouselCaption as Caption,\n\tCarouselIndicator as Indicator,\n\tCarouselIndicatorGroup as IndicatorWrapper,\n} from \"./carousel\";\n"]}
|
|
@@ -1,510 +0,0 @@
|
|
|
1
|
-
import { cnMerge } from './chunk-OHG7GB7O.js';
|
|
2
|
-
import { getElementList } from './chunk-DW3FXTFL.js';
|
|
3
|
-
import { Slot } from './chunk-ENDWJXPF.js';
|
|
4
|
-
import { __export } from './chunk-PZ5AY32C.js';
|
|
5
|
-
import * as React2 from 'react';
|
|
6
|
-
import { Fragment, useId, useMemo, useRef, useEffect } from 'react';
|
|
7
|
-
import { toArray } from '@zayne-labs/toolkit-core';
|
|
8
|
-
import { createCustomContext, useToggle, ContextError } from '@zayne-labs/toolkit-react';
|
|
9
|
-
import { getMultipleSlots } from '@zayne-labs/toolkit-react/utils';
|
|
10
|
-
import { defineEnum } from '@zayne-labs/toolkit-type-helpers';
|
|
11
|
-
import { useFormState, useWatch, FormProvider, Controller, useFormContext } from 'react-hook-form';
|
|
12
|
-
export { useFormContext } from 'react-hook-form';
|
|
13
|
-
|
|
14
|
-
var EyeIconInvisible = (props) => /* @__PURE__ */ React2.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "1em", height: "1em", viewBox: "0 0 24 24", ...props }, /* @__PURE__ */ React2.createElement(
|
|
15
|
-
"path",
|
|
16
|
-
{
|
|
17
|
-
fill: "currentColor",
|
|
18
|
-
d: "M15.175 8.325q.725.725 1.063 1.65t.237 1.9q0 .375-.275.638t-.65.262t-.638-.262t-.262-.638q.125-.65-.075-1.25T13.95 9.6t-1.025-.65t-1.275-.1q-.375 0-.638-.275t-.262-.65t.263-.637t.637-.263q.95-.1 1.875.238t1.65 1.062M12 6q-.475 0-.925.037t-.9.138q-.425.075-.763-.125t-.462-.6t.088-.775t.612-.45q.575-.125 1.163-.175T12 4q3.425 0 6.263 1.8t4.337 4.85q.1.2.15.413t.05.437t-.038.438t-.137.412q-.45 1-1.112 1.875t-1.463 1.6q-.3.275-.7.225t-.65-.4t-.212-.763t.337-.687q.6-.575 1.1-1.25t.875-1.45q-1.25-2.525-3.613-4.012T12 6m0 13q-3.35 0-6.125-1.812T1.5 12.425q-.125-.2-.187-.437T1.25 11.5t.05-.475t.175-.45q.5-1 1.163-1.912T4.15 7L2.075 4.9q-.275-.3-.262-.712T2.1 3.5t.7-.275t.7.275l17 17q.275.275.288.688t-.288.712q-.275.275-.7.275t-.7-.275l-3.5-3.45q-.875.275-1.775.413T12 19M5.55 8.4q-.725.65-1.325 1.425T3.2 11.5q1.25 2.525 3.613 4.013T12 17q.5 0 .975-.062t.975-.138l-.9-.95q-.275.075-.525.113T12 16q-1.875 0-3.188-1.312T7.5 11.5q0-.275.038-.525t.112-.525zm4.2 4.2"
|
|
19
|
-
}
|
|
20
|
-
));
|
|
21
|
-
var EyeIconVisible = (props) => /* @__PURE__ */ React2.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "1em", height: "1em", viewBox: "0 0 24 24", ...props }, /* @__PURE__ */ React2.createElement(
|
|
22
|
-
"path",
|
|
23
|
-
{
|
|
24
|
-
fill: "currentColor",
|
|
25
|
-
d: "M12 16q1.875 0 3.188-1.312T16.5 11.5t-1.312-3.187T12 7T8.813 8.313T7.5 11.5t1.313 3.188T12 16m0-1.8q-1.125 0-1.912-.788T9.3 11.5t.788-1.912T12 8.8t1.913.788t.787 1.912t-.787 1.913T12 14.2m0 4.8q-3.35 0-6.113-1.8t-4.362-4.75q-.125-.225-.187-.462t-.063-.488t.063-.488t.187-.462q1.6-2.95 4.363-4.75T12 4t6.113 1.8t4.362 4.75q.125.225.188.463t.062.487t-.062.488t-.188.462q-1.6 2.95-4.362 4.75T12 19m0-2q2.825 0 5.188-1.487T20.8 11.5q-1.25-2.525-3.613-4.012T12 6T6.813 7.488T3.2 11.5q1.25 2.525 3.613 4.013T12 17"
|
|
26
|
-
}
|
|
27
|
-
));
|
|
28
|
-
var useFormRootContext = (options = {}) => {
|
|
29
|
-
const { strict = true } = options;
|
|
30
|
-
const formContext = useFormContext();
|
|
31
|
-
if (strict && !formContext) {
|
|
32
|
-
throw new ContextError(
|
|
33
|
-
`useFormRootContext returned "null". Did you forget to wrap the necessary components within FormRoot?`
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
return formContext;
|
|
37
|
-
};
|
|
38
|
-
var useLaxFormFieldState = (options) => {
|
|
39
|
-
const { control = options?.control } = useFormRootContext({ strict: false }) ?? {};
|
|
40
|
-
const { name = options?.name } = useLaxFormFieldContext() ?? {};
|
|
41
|
-
const getFormState = control ? useFormState : () => ({});
|
|
42
|
-
const { disabled, errors } = getFormState({ control, name });
|
|
43
|
-
return { errors, isDisabled: disabled, isInvalid: Boolean(options?.name && errors?.[options.name]) };
|
|
44
|
-
};
|
|
45
|
-
var [StrictFormFieldProvider, useStrictFormFieldContext] = createCustomContext(
|
|
46
|
-
{
|
|
47
|
-
hookName: "useFormFieldContext",
|
|
48
|
-
name: "StrictFormFieldContext",
|
|
49
|
-
providerName: "FormField"
|
|
50
|
-
}
|
|
51
|
-
);
|
|
52
|
-
var [LaxFormFieldProvider, useLaxFormFieldContext] = createCustomContext({
|
|
53
|
-
hookName: "useLaxFormFieldContext",
|
|
54
|
-
name: "LaxFormFieldContext",
|
|
55
|
-
providerName: "FormField",
|
|
56
|
-
strict: false
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
// src/components/ui/form/form.tsx
|
|
60
|
-
var dataAttr = (condition) => condition ? "" : void 0;
|
|
61
|
-
function FormRoot(props) {
|
|
62
|
-
const { children, className, methods, ...restOfProps } = props;
|
|
63
|
-
return /* @__PURE__ */ React2.createElement(FormProvider, { ...methods }, /* @__PURE__ */ React2.createElement(
|
|
64
|
-
"form",
|
|
65
|
-
{
|
|
66
|
-
className: cnMerge("flex flex-col", className),
|
|
67
|
-
...restOfProps,
|
|
68
|
-
"data-scope": "form",
|
|
69
|
-
"data-part": "root"
|
|
70
|
-
},
|
|
71
|
-
children
|
|
72
|
-
));
|
|
73
|
-
}
|
|
74
|
-
function FormField(props) {
|
|
75
|
-
const { children, className, name, withWrapper = true } = props;
|
|
76
|
-
const { isDisabled, isInvalid } = useLaxFormFieldState({ name });
|
|
77
|
-
const uniqueId = useId();
|
|
78
|
-
const fieldContextValue = useMemo(
|
|
79
|
-
() => ({
|
|
80
|
-
formDescriptionId: `${name}-(${uniqueId})-form-item-description`,
|
|
81
|
-
formItemId: `${name}-(${uniqueId})-form-item`,
|
|
82
|
-
formMessageId: `${name}-(${uniqueId})-form-item-message`,
|
|
83
|
-
name
|
|
84
|
-
}),
|
|
85
|
-
[name, uniqueId]
|
|
86
|
-
);
|
|
87
|
-
const WrapperElement = withWrapper ? "div" : Fragment;
|
|
88
|
-
const wrapperElementProps = withWrapper && {
|
|
89
|
-
className: cnMerge("flex flex-col", className),
|
|
90
|
-
"data-part": "field",
|
|
91
|
-
"data-scope": "form",
|
|
92
|
-
/* eslint-disable perfectionist/sort-objects -- order of attributes does not matter */
|
|
93
|
-
"data-disabled": dataAttr(isDisabled),
|
|
94
|
-
"data-invalid": dataAttr(isInvalid)
|
|
95
|
-
/* eslint-enable perfectionist/sort-objects -- order of attributes does not matter */
|
|
96
|
-
};
|
|
97
|
-
return /* @__PURE__ */ React2.createElement(StrictFormFieldProvider, { value: fieldContextValue }, /* @__PURE__ */ React2.createElement(LaxFormFieldProvider, { value: fieldContextValue }, /* @__PURE__ */ React2.createElement(WrapperElement, { ...wrapperElementProps }, children)));
|
|
98
|
-
}
|
|
99
|
-
function FormControlledField(props) {
|
|
100
|
-
const { name } = props;
|
|
101
|
-
const uniqueId = useId();
|
|
102
|
-
const fieldContextValue = useMemo(
|
|
103
|
-
() => ({
|
|
104
|
-
formDescriptionId: `${name}-(${uniqueId})-form-item-description`,
|
|
105
|
-
formItemId: `${name}-(${uniqueId})-form-item`,
|
|
106
|
-
formMessageId: `${name}-(${uniqueId})-form-item-message`,
|
|
107
|
-
name
|
|
108
|
-
}),
|
|
109
|
-
[name, uniqueId]
|
|
110
|
-
);
|
|
111
|
-
return /* @__PURE__ */ React2.createElement(StrictFormFieldProvider, { value: fieldContextValue }, /* @__PURE__ */ React2.createElement(LaxFormFieldProvider, { value: fieldContextValue }, /* @__PURE__ */ React2.createElement(Controller, { ...props })));
|
|
112
|
-
}
|
|
113
|
-
function FormFieldController(props) {
|
|
114
|
-
const { control } = useFormRootContext();
|
|
115
|
-
const { name } = useStrictFormFieldContext();
|
|
116
|
-
const { render, ...restOfProps } = props;
|
|
117
|
-
return /* @__PURE__ */ React2.createElement(Controller, { name, control, render, ...restOfProps });
|
|
118
|
-
}
|
|
119
|
-
function FormFieldContext(props) {
|
|
120
|
-
const { children, render } = props;
|
|
121
|
-
const fieldContextValues = useStrictFormFieldContext();
|
|
122
|
-
if (typeof children === "function") {
|
|
123
|
-
return children(fieldContextValues);
|
|
124
|
-
}
|
|
125
|
-
return render(fieldContextValues);
|
|
126
|
-
}
|
|
127
|
-
function FormLabel(props) {
|
|
128
|
-
const { formItemId, name } = useStrictFormFieldContext();
|
|
129
|
-
const { children, className, ...restOfProps } = props;
|
|
130
|
-
const { isDisabled, isInvalid } = useLaxFormFieldState({ name });
|
|
131
|
-
return /* @__PURE__ */ React2.createElement(
|
|
132
|
-
"label",
|
|
133
|
-
{
|
|
134
|
-
"data-scope": "form",
|
|
135
|
-
"data-part": "label",
|
|
136
|
-
"data-disabled": dataAttr(isDisabled),
|
|
137
|
-
"data-invalid": dataAttr(isInvalid),
|
|
138
|
-
htmlFor: formItemId,
|
|
139
|
-
className,
|
|
140
|
-
...restOfProps
|
|
141
|
-
},
|
|
142
|
-
children
|
|
143
|
-
);
|
|
144
|
-
}
|
|
145
|
-
function FormInputGroup(props) {
|
|
146
|
-
const { children, className, ...restOfProps } = props;
|
|
147
|
-
const { isDisabled, isInvalid } = useLaxFormFieldState();
|
|
148
|
-
const {
|
|
149
|
-
regularChildren,
|
|
150
|
-
slots: [leftItemSlot, rightItemSlot]
|
|
151
|
-
} = getMultipleSlots(children, [FormInputLeftItem, FormInputRightItem]);
|
|
152
|
-
return /* @__PURE__ */ React2.createElement(
|
|
153
|
-
"div",
|
|
154
|
-
{
|
|
155
|
-
"data-scope": "form",
|
|
156
|
-
"data-part": "input-group",
|
|
157
|
-
"data-invalid": dataAttr(isInvalid),
|
|
158
|
-
"data-disabled": dataAttr(isDisabled),
|
|
159
|
-
className: cnMerge("flex items-center justify-between gap-2", className),
|
|
160
|
-
...restOfProps
|
|
161
|
-
},
|
|
162
|
-
leftItemSlot,
|
|
163
|
-
regularChildren,
|
|
164
|
-
rightItemSlot
|
|
165
|
-
);
|
|
166
|
-
}
|
|
167
|
-
function FormInputLeftItem(props) {
|
|
168
|
-
const { as: Element = "span", children, className, ...restOfProps } = props;
|
|
169
|
-
return /* @__PURE__ */ React2.createElement(
|
|
170
|
-
Element,
|
|
171
|
-
{
|
|
172
|
-
"data-scope": "form",
|
|
173
|
-
"data-part": "left-item",
|
|
174
|
-
className: cnMerge("inline-flex items-center justify-center", className),
|
|
175
|
-
...restOfProps
|
|
176
|
-
},
|
|
177
|
-
children
|
|
178
|
-
);
|
|
179
|
-
}
|
|
180
|
-
FormInputLeftItem.slotSymbol = Symbol("leftItem");
|
|
181
|
-
function FormInputRightItem(props) {
|
|
182
|
-
const { as: Element = "span", children, className, ...restOfProps } = props;
|
|
183
|
-
return /* @__PURE__ */ React2.createElement(
|
|
184
|
-
Element,
|
|
185
|
-
{
|
|
186
|
-
"data-scope": "form",
|
|
187
|
-
"data-part": "right-item",
|
|
188
|
-
className: cnMerge("inline-flex items-center justify-center", className),
|
|
189
|
-
...restOfProps
|
|
190
|
-
},
|
|
191
|
-
children
|
|
192
|
-
);
|
|
193
|
-
}
|
|
194
|
-
FormInputRightItem.slotSymbol = Symbol("rightItem");
|
|
195
|
-
var inputTypesWithoutFullWith = /* @__PURE__ */ new Set(["checkbox", "radio"]);
|
|
196
|
-
function FormInputPrimitive(props) {
|
|
197
|
-
const fieldContextValues = useLaxFormFieldContext();
|
|
198
|
-
const {
|
|
199
|
-
className,
|
|
200
|
-
classNames,
|
|
201
|
-
control,
|
|
202
|
-
fieldState,
|
|
203
|
-
id = fieldContextValues?.formItemId,
|
|
204
|
-
name = fieldContextValues?.name,
|
|
205
|
-
rules,
|
|
206
|
-
type = "text",
|
|
207
|
-
withEyeIcon = true,
|
|
208
|
-
...restOfProps
|
|
209
|
-
} = props;
|
|
210
|
-
const fieldStateFromLaxFormField = useLaxFormFieldState({ control, name });
|
|
211
|
-
const { isDisabled, isInvalid } = fieldState ?? fieldStateFromLaxFormField;
|
|
212
|
-
const [isPasswordVisible, toggleVisibility] = useToggle(false);
|
|
213
|
-
const shouldHaveEyeIcon = withEyeIcon && type === "password";
|
|
214
|
-
const WrapperElement = shouldHaveEyeIcon ? FormInputGroup : Fragment;
|
|
215
|
-
const wrapperElementProps = shouldHaveEyeIcon && {
|
|
216
|
-
className: cnMerge("w-full", classNames?.inputGroup, isInvalid && classNames?.error),
|
|
217
|
-
"data-disabled": dataAttr(isDisabled),
|
|
218
|
-
"data-invalid": dataAttr(isInvalid)
|
|
219
|
-
};
|
|
220
|
-
const { register } = useFormRootContext({ strict: false }) ?? {};
|
|
221
|
-
return /* @__PURE__ */ React2.createElement(WrapperElement, { ...wrapperElementProps }, /* @__PURE__ */ React2.createElement(
|
|
222
|
-
"input",
|
|
223
|
-
{
|
|
224
|
-
"data-scope": "form",
|
|
225
|
-
"data-part": "input",
|
|
226
|
-
"aria-describedby": !isInvalid ? fieldContextValues?.formDescriptionId : `${fieldContextValues?.formDescriptionId} ${fieldContextValues?.formMessageId}`,
|
|
227
|
-
"aria-invalid": dataAttr(isInvalid),
|
|
228
|
-
"data-invalid": dataAttr(isInvalid),
|
|
229
|
-
"data-disabled": dataAttr(isDisabled),
|
|
230
|
-
id,
|
|
231
|
-
name,
|
|
232
|
-
type: type === "password" && isPasswordVisible ? "text" : type,
|
|
233
|
-
className: cnMerge(
|
|
234
|
-
!inputTypesWithoutFullWith.has(type) && "flex w-full",
|
|
235
|
-
`bg-transparent text-sm file:border-0 file:bg-transparent
|
|
236
|
-
placeholder:text-shadcn-muted-foreground focus-visible:outline-hidden
|
|
237
|
-
disabled:cursor-not-allowed disabled:opacity-50`,
|
|
238
|
-
className,
|
|
239
|
-
classNames?.input,
|
|
240
|
-
type !== "password" && isInvalid && classNames?.error
|
|
241
|
-
),
|
|
242
|
-
...Boolean(name) && register?.(name, rules),
|
|
243
|
-
...restOfProps
|
|
244
|
-
}
|
|
245
|
-
), shouldHaveEyeIcon && /* @__PURE__ */ React2.createElement(
|
|
246
|
-
FormInputRightItem,
|
|
247
|
-
{
|
|
248
|
-
as: "button",
|
|
249
|
-
type: "button",
|
|
250
|
-
onClick: toggleVisibility,
|
|
251
|
-
className: "size-5 shrink-0 lg:size-6"
|
|
252
|
-
},
|
|
253
|
-
isPasswordVisible ? /* @__PURE__ */ React2.createElement(EyeIconInvisible, { className: cnMerge("size-full", classNames?.eyeIcon) }) : /* @__PURE__ */ React2.createElement(EyeIconVisible, { className: cnMerge("size-full", classNames?.eyeIcon) })
|
|
254
|
-
));
|
|
255
|
-
}
|
|
256
|
-
function FormTextAreaPrimitive(props) {
|
|
257
|
-
const fieldContextValues = useLaxFormFieldContext();
|
|
258
|
-
const {
|
|
259
|
-
className,
|
|
260
|
-
classNames,
|
|
261
|
-
control,
|
|
262
|
-
fieldState,
|
|
263
|
-
id = fieldContextValues?.formItemId,
|
|
264
|
-
name = fieldContextValues?.name,
|
|
265
|
-
rules,
|
|
266
|
-
...restOfProps
|
|
267
|
-
} = props;
|
|
268
|
-
const fieldStateFromLaxFormField = useLaxFormFieldState({ control, name });
|
|
269
|
-
const { isDisabled, isInvalid } = fieldState ?? fieldStateFromLaxFormField;
|
|
270
|
-
const { register } = useFormRootContext({ strict: false }) ?? {};
|
|
271
|
-
return /* @__PURE__ */ React2.createElement(
|
|
272
|
-
"textarea",
|
|
273
|
-
{
|
|
274
|
-
"data-scope": "form",
|
|
275
|
-
"data-part": "textarea",
|
|
276
|
-
"aria-describedby": !isInvalid ? fieldContextValues?.formDescriptionId : `${fieldContextValues?.formDescriptionId} ${fieldContextValues?.formMessageId}`,
|
|
277
|
-
"aria-invalid": dataAttr(isInvalid),
|
|
278
|
-
"data-disabled": dataAttr(isDisabled),
|
|
279
|
-
"data-invalid": dataAttr(isInvalid),
|
|
280
|
-
id,
|
|
281
|
-
name,
|
|
282
|
-
className: cnMerge(
|
|
283
|
-
`w-full bg-transparent text-sm placeholder:text-shadcn-muted-foreground
|
|
284
|
-
focus-visible:outline-hidden disabled:cursor-not-allowed disabled:opacity-50`,
|
|
285
|
-
className,
|
|
286
|
-
classNames?.base,
|
|
287
|
-
isInvalid && classNames?.error
|
|
288
|
-
),
|
|
289
|
-
...Boolean(name) && register?.(name, rules),
|
|
290
|
-
...restOfProps
|
|
291
|
-
}
|
|
292
|
-
);
|
|
293
|
-
}
|
|
294
|
-
function FormSelectPrimitive(props) {
|
|
295
|
-
const fieldContextValues = useLaxFormFieldContext();
|
|
296
|
-
const {
|
|
297
|
-
className,
|
|
298
|
-
classNames,
|
|
299
|
-
control,
|
|
300
|
-
fieldState,
|
|
301
|
-
id = fieldContextValues?.formItemId,
|
|
302
|
-
name = fieldContextValues?.name,
|
|
303
|
-
rules,
|
|
304
|
-
...restOfProps
|
|
305
|
-
} = props;
|
|
306
|
-
const fieldStateFromLaxFormField = useLaxFormFieldState({ control, name });
|
|
307
|
-
const { isDisabled, isInvalid } = fieldState ?? fieldStateFromLaxFormField;
|
|
308
|
-
const { register } = useFormRootContext({ strict: false }) ?? {};
|
|
309
|
-
return /* @__PURE__ */ React2.createElement(
|
|
310
|
-
"select",
|
|
311
|
-
{
|
|
312
|
-
defaultValue: "",
|
|
313
|
-
"data-scope": "form",
|
|
314
|
-
"data-part": "select",
|
|
315
|
-
"aria-describedby": !isInvalid ? fieldContextValues?.formDescriptionId : `${fieldContextValues?.formDescriptionId} ${fieldContextValues?.formMessageId}`,
|
|
316
|
-
"aria-invalid": dataAttr(isInvalid),
|
|
317
|
-
"data-disabled": dataAttr(isDisabled),
|
|
318
|
-
"data-invalid": dataAttr(isInvalid),
|
|
319
|
-
id,
|
|
320
|
-
name,
|
|
321
|
-
className: cnMerge(
|
|
322
|
-
`w-full bg-transparent text-sm placeholder:text-shadcn-muted-foreground
|
|
323
|
-
focus-visible:outline-hidden disabled:cursor-not-allowed disabled:opacity-50`,
|
|
324
|
-
className,
|
|
325
|
-
classNames?.base,
|
|
326
|
-
isInvalid && classNames?.error
|
|
327
|
-
),
|
|
328
|
-
...Boolean(name) && register?.(name, rules),
|
|
329
|
-
...restOfProps
|
|
330
|
-
}
|
|
331
|
-
);
|
|
332
|
-
}
|
|
333
|
-
var InputTypeMap = defineEnum({
|
|
334
|
-
select: FormSelectPrimitive,
|
|
335
|
-
textarea: FormTextAreaPrimitive
|
|
336
|
-
});
|
|
337
|
-
function FormInput(props) {
|
|
338
|
-
const { rules, type, ...restOfProps } = props;
|
|
339
|
-
const { name } = useStrictFormFieldContext();
|
|
340
|
-
const { register } = useFormRootContext();
|
|
341
|
-
const SelectedInput = type === "textarea" || type === "select" ? InputTypeMap[type] : FormInputPrimitive;
|
|
342
|
-
return /* @__PURE__ */ React2.createElement(
|
|
343
|
-
SelectedInput,
|
|
344
|
-
{
|
|
345
|
-
type,
|
|
346
|
-
name,
|
|
347
|
-
...Boolean(name) && register(name, rules),
|
|
348
|
-
...restOfProps
|
|
349
|
-
}
|
|
350
|
-
);
|
|
351
|
-
}
|
|
352
|
-
function FormTextArea(props) {
|
|
353
|
-
return /* @__PURE__ */ React2.createElement(FormInput, { type: "textarea", ...props });
|
|
354
|
-
}
|
|
355
|
-
function FormSelect(props) {
|
|
356
|
-
return /* @__PURE__ */ React2.createElement(FormInput, { type: "select", ...props });
|
|
357
|
-
}
|
|
358
|
-
function FormDescription(props) {
|
|
359
|
-
const { className, ...restOfProps } = props;
|
|
360
|
-
const { formDescriptionId } = useLaxFormFieldContext() ?? {};
|
|
361
|
-
return /* @__PURE__ */ React2.createElement("p", { id: formDescriptionId, className: cnMerge("text-[12px]", className), ...restOfProps });
|
|
362
|
-
}
|
|
363
|
-
var FormErrorMessagePrimitive = (props) => {
|
|
364
|
-
const fieldContextValues = useLaxFormFieldContext();
|
|
365
|
-
const rootContextValues = useFormRootContext({ strict: false });
|
|
366
|
-
const {
|
|
367
|
-
children,
|
|
368
|
-
className,
|
|
369
|
-
classNames,
|
|
370
|
-
control = rootContextValues?.control,
|
|
371
|
-
errorField = fieldContextValues?.name,
|
|
372
|
-
render,
|
|
373
|
-
type = "regular",
|
|
374
|
-
withAnimationOnInvalid = true
|
|
375
|
-
} = props;
|
|
376
|
-
const { errors } = useLaxFormFieldState({ control, name: errorField });
|
|
377
|
-
const { formMessageId } = useLaxFormFieldContext() ?? {};
|
|
378
|
-
const wrapperRef = useRef(null);
|
|
379
|
-
const errorAnimationClass = classNames?.errorMessageAnimation ?? "animate-shake";
|
|
380
|
-
useEffect(() => {
|
|
381
|
-
if (!withAnimationOnInvalid) return;
|
|
382
|
-
const errorMessageElements = wrapperRef.current?.children;
|
|
383
|
-
if (!errorMessageElements) return;
|
|
384
|
-
for (const element of errorMessageElements) {
|
|
385
|
-
element.classList.add(errorAnimationClass);
|
|
386
|
-
}
|
|
387
|
-
}, [errorAnimationClass, withAnimationOnInvalid]);
|
|
388
|
-
useEffect(() => {
|
|
389
|
-
const errorMessageElements = wrapperRef.current?.children;
|
|
390
|
-
if (!errorMessageElements || !errors) return;
|
|
391
|
-
if (Object.keys(errors).indexOf(errorField) === 0) {
|
|
392
|
-
errorMessageElements[0]?.scrollIntoView({
|
|
393
|
-
behavior: "smooth",
|
|
394
|
-
block: "center"
|
|
395
|
-
});
|
|
396
|
-
window.scrollBy({ behavior: "smooth", top: -100 });
|
|
397
|
-
}
|
|
398
|
-
}, [errorField, errors]);
|
|
399
|
-
const message = type === "root" ? errors?.root?.[errorField]?.message : errors?.[errorField]?.message;
|
|
400
|
-
if (!message) {
|
|
401
|
-
return null;
|
|
402
|
-
}
|
|
403
|
-
const errorMessageArray = toArray(message);
|
|
404
|
-
const [ErrorMessageList] = getElementList();
|
|
405
|
-
const onAnimationEnd = withAnimationOnInvalid ? (event) => event.currentTarget.classList.remove(errorAnimationClass) : void 0;
|
|
406
|
-
const getRenderProps = ({ index }) => ({
|
|
407
|
-
className: cnMerge(errorAnimationClass, className, classNames?.errorMessage),
|
|
408
|
-
"data-index": index,
|
|
409
|
-
"data-part": "error-message",
|
|
410
|
-
"data-scope": "form",
|
|
411
|
-
id: formMessageId,
|
|
412
|
-
onAnimationEnd
|
|
413
|
-
});
|
|
414
|
-
const getRenderState = ({ errorMessage, index }) => ({
|
|
415
|
-
errorMessage,
|
|
416
|
-
errorMessageArray,
|
|
417
|
-
index
|
|
418
|
-
});
|
|
419
|
-
const renderFn = typeof children === "function" ? children : render;
|
|
420
|
-
return /* @__PURE__ */ React2.createElement(
|
|
421
|
-
ErrorMessageList,
|
|
422
|
-
{
|
|
423
|
-
each: errorMessageArray,
|
|
424
|
-
ref: wrapperRef,
|
|
425
|
-
className: cnMerge("flex flex-col", classNames?.container),
|
|
426
|
-
render: (errorMessage, index) => {
|
|
427
|
-
return renderFn({
|
|
428
|
-
props: getRenderProps({ index }),
|
|
429
|
-
state: getRenderState({ errorMessage, index })
|
|
430
|
-
});
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
);
|
|
434
|
-
};
|
|
435
|
-
function FormErrorMessage(props) {
|
|
436
|
-
const fieldContextValues = useLaxFormFieldContext();
|
|
437
|
-
const { className, errorField = fieldContextValues?.name, type = "regular" } = props;
|
|
438
|
-
const { control } = useFormRootContext();
|
|
439
|
-
return /* @__PURE__ */ React2.createElement(
|
|
440
|
-
FormErrorMessagePrimitive,
|
|
441
|
-
{
|
|
442
|
-
control,
|
|
443
|
-
errorField,
|
|
444
|
-
type,
|
|
445
|
-
render: ({ props: renderProps, state: { errorMessage } }) => /* @__PURE__ */ React2.createElement(
|
|
446
|
-
"p",
|
|
447
|
-
{
|
|
448
|
-
...renderProps,
|
|
449
|
-
key: errorMessage,
|
|
450
|
-
className: cnMerge("text-[13px]", "data-[index=0]:mt-1", renderProps.className, className)
|
|
451
|
-
},
|
|
452
|
-
errorMessage
|
|
453
|
-
)
|
|
454
|
-
}
|
|
455
|
-
);
|
|
456
|
-
}
|
|
457
|
-
function FormSubmit(props) {
|
|
458
|
-
const { as: Element = "button", asChild, children, type = "submit", ...restOfProps } = props;
|
|
459
|
-
const Component = asChild ? Slot : Element;
|
|
460
|
-
return /* @__PURE__ */ React2.createElement(Component, { type, ...restOfProps }, children);
|
|
461
|
-
}
|
|
462
|
-
function FormSubscribeToFieldValue(props) {
|
|
463
|
-
const fieldContextValues = useLaxFormFieldContext();
|
|
464
|
-
const { children, name = fieldContextValues?.name, render } = props;
|
|
465
|
-
const { control } = useFormRootContext();
|
|
466
|
-
const formValue = useWatch({ control, name });
|
|
467
|
-
const fieldProps = { value: formValue };
|
|
468
|
-
if (typeof children === "function") {
|
|
469
|
-
return children(fieldProps);
|
|
470
|
-
}
|
|
471
|
-
return render(fieldProps);
|
|
472
|
-
}
|
|
473
|
-
function FormSubscribeToFormState(props) {
|
|
474
|
-
const fieldContextValues = useLaxFormFieldContext();
|
|
475
|
-
const { children, control, name = fieldContextValues?.name, render } = props;
|
|
476
|
-
const formState = useFormState({ control, name });
|
|
477
|
-
if (typeof children === "function") {
|
|
478
|
-
return children(formState);
|
|
479
|
-
}
|
|
480
|
-
return render(formState);
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
// src/components/ui/form/form-parts.ts
|
|
484
|
-
var form_parts_exports = {};
|
|
485
|
-
__export(form_parts_exports, {
|
|
486
|
-
ControlledField: () => FormControlledField,
|
|
487
|
-
Description: () => FormDescription,
|
|
488
|
-
ErrorMessage: () => FormErrorMessage,
|
|
489
|
-
ErrorMessagePrimitive: () => FormErrorMessagePrimitive,
|
|
490
|
-
Field: () => FormField,
|
|
491
|
-
FieldContext: () => FormFieldContext,
|
|
492
|
-
FieldController: () => FormFieldController,
|
|
493
|
-
Input: () => FormInput,
|
|
494
|
-
InputGroup: () => FormInputGroup,
|
|
495
|
-
InputLeftItem: () => FormInputLeftItem,
|
|
496
|
-
InputPrimitive: () => FormInputPrimitive,
|
|
497
|
-
InputRightItem: () => FormInputRightItem,
|
|
498
|
-
Label: () => FormLabel,
|
|
499
|
-
Root: () => FormRoot,
|
|
500
|
-
Select: () => FormSelect,
|
|
501
|
-
Submit: () => FormSubmit,
|
|
502
|
-
SubscribeToFieldValue: () => FormSubscribeToFieldValue,
|
|
503
|
-
SubscribeToFormState: () => FormSubscribeToFormState,
|
|
504
|
-
TextArea: () => FormTextArea,
|
|
505
|
-
TextAreaPrimitive: () => FormTextAreaPrimitive
|
|
506
|
-
});
|
|
507
|
-
|
|
508
|
-
export { FormControlledField, FormDescription, FormErrorMessage, FormErrorMessagePrimitive, FormField, FormFieldContext, FormFieldController, FormInput, FormInputGroup, FormInputLeftItem, FormInputPrimitive, FormInputRightItem, FormLabel, FormRoot, FormSelect, FormSelectPrimitive, FormSubmit, FormSubscribeToFieldValue, FormSubscribeToFormState, FormTextArea, FormTextAreaPrimitive, form_parts_exports, useStrictFormFieldContext };
|
|
509
|
-
//# sourceMappingURL=chunk-IJUYDZCZ.js.map
|
|
510
|
-
//# sourceMappingURL=chunk-IJUYDZCZ.js.map
|