@verbb/plugin-kit-react 1.0.7 → 1.0.9
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/CHANGELOG.md +20 -0
- package/dist/components/Command.d.ts +5 -5
- package/dist/components/Command.d.ts.map +1 -1
- package/dist/components/DropdownMenu.d.ts +1 -1
- package/dist/components/DropdownMenu.d.ts.map +1 -1
- package/dist/components/DropdownMenu.js +3 -1
- package/dist/components/DropdownMenu.js.map +1 -1
- package/dist/components/PaneTabs.d.ts.map +1 -1
- package/dist/components/PaneTabs.js +1 -1
- package/dist/components/PaneTabs.js.map +1 -1
- package/dist/forms/Field.d.ts +2 -1
- package/dist/forms/Field.d.ts.map +1 -1
- package/dist/forms/Field.js +24 -12
- package/dist/forms/Field.js.map +1 -1
- package/dist/forms/TranslationIcon.d.ts +5 -0
- package/dist/forms/TranslationIcon.d.ts.map +1 -0
- package/dist/forms/TranslationIcon.js +18 -0
- package/dist/forms/TranslationIcon.js.map +1 -0
- package/dist/forms/fields/ListField.d.ts +1 -0
- package/dist/forms/fields/ListField.d.ts.map +1 -1
- package/dist/forms/fields/ListField.js +1 -0
- package/dist/forms/fields/ListField.js.map +1 -1
- package/dist/forms/fields/RichTextField.d.ts +1 -0
- package/dist/forms/fields/RichTextField.d.ts.map +1 -1
- package/dist/forms/fields/RichTextField.js +1 -0
- package/dist/forms/fields/RichTextField.js.map +1 -1
- package/dist/forms/fields/SelectField.d.ts.map +1 -1
- package/dist/forms/fields/SelectField.js +2 -1
- package/dist/forms/fields/SelectField.js.map +1 -1
- package/dist/forms/fields/TextField.d.ts +1 -0
- package/dist/forms/fields/TextField.d.ts.map +1 -1
- package/dist/forms/fields/TextField.js +1 -0
- package/dist/forms/fields/TextField.js.map +1 -1
- package/dist/forms/fields/TextareaField.d.ts +1 -0
- package/dist/forms/fields/TextareaField.d.ts.map +1 -1
- package/dist/forms/fields/TextareaField.js +1 -0
- package/dist/forms/fields/TextareaField.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 1.0.9 - 2026-07-02
|
|
6
|
+
|
|
7
|
+
### Changed
|
|
8
|
+
- Changed `DropdownMenuContent` to default to `positionMethod="fixed"` when portaling into a Shadow DOM container, and added an optional `positionMethod` prop to override the default.
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
- Fixed dropdown menus rendering with a large positional offset inside Shadow DOM apps such as the Formie form builder.
|
|
12
|
+
- Fixed `PaneTabsContent` showing a focus ring when the tab panel received focus, leaving focus styling on the tab trigger only.
|
|
13
|
+
|
|
14
|
+
## 1.0.8 - 2026-06-23
|
|
15
|
+
|
|
16
|
+
### Added
|
|
17
|
+
- Added a translation icon to `FieldLayout` for schema fields marked `translatable`.
|
|
18
|
+
- Added `TranslationIcon` for host apps that need the same translatable-field affordance outside `FieldLayout`.
|
|
19
|
+
- Added `translatable` support to `TextField`, `TextareaField`, and `RichTextField`.
|
|
20
|
+
- Added `className` support to `ListField`.
|
|
21
|
+
|
|
22
|
+
### Fixed
|
|
23
|
+
- Fixed `SelectField` ignoring the schema `disabled` property and leaving the select interactive when it should be read-only.
|
|
24
|
+
|
|
5
25
|
## 1.0.7 - 2026-06-18
|
|
6
26
|
|
|
7
27
|
### Added
|
|
@@ -9,14 +9,14 @@ declare function CommandDialog({ title, description, children, showCloseButton,
|
|
|
9
9
|
}): import("react/jsx-runtime").JSX.Element;
|
|
10
10
|
declare function CommandInput({ className, ...props }: ComponentProps<typeof CommandPrimitive.Input>): import("react/jsx-runtime").JSX.Element;
|
|
11
11
|
declare const CommandList: React.ForwardRefExoticComponent<Omit<{
|
|
12
|
-
children?:
|
|
13
|
-
} & Pick<Pick<
|
|
14
|
-
ref?:
|
|
12
|
+
children?: React.ReactNode;
|
|
13
|
+
} & Pick<Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof React.HTMLAttributes<HTMLDivElement>> & {
|
|
14
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
15
15
|
} & {
|
|
16
16
|
asChild?: boolean;
|
|
17
|
-
}, "key" |
|
|
17
|
+
}, "key" | keyof React.HTMLAttributes<HTMLDivElement> | "asChild"> & {
|
|
18
18
|
label?: string;
|
|
19
|
-
} &
|
|
19
|
+
} & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
20
20
|
declare function CommandEmpty({ ...props }: ComponentProps<typeof CommandPrimitive.Empty>): import("react/jsx-runtime").JSX.Element;
|
|
21
21
|
declare function CommandGroup({ className, ...props }: ComponentProps<typeof CommandPrimitive.Group>): import("react/jsx-runtime").JSX.Element;
|
|
22
22
|
declare function CommandSeparator({ className, ...props }: ComponentProps<typeof CommandPrimitive.Separator>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Command.d.ts","sourceRoot":"","sources":["../../src/components/Command.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,cAAc,EAAkB,MAAM,OAAO,CAAC;AAG9D,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AAEpE,OAAO,EACH,MAAM,EACT,MAAM,oCAAoC,CAAC;AAI5C,iBAAS,OAAO,CAAC,EACb,SAAS,EACT,GAAG,KAAK,EACX,EAAE,cAAc,CAAC,OAAO,gBAAgB,CAAC,2CAkBzC;AAED,iBAAS,aAAa,CAAC,EACnB,KAAyB,EACzB,WAA8C,EAC9C,QAAQ,EACR,eAAsB,EACtB,GAAG,KAAK,EACX,EAAE,cAAc,CAAC,OAAO,MAAM,CAAC,GAAG;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,eAAe,CAAC,EAAE,OAAO,CAAA;CAC5B,2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G,KAAK,EACX,EAAE,cAAc,CAAC,OAAO,gBAAgB,CAAC,SAAS,CAAC,2CAmBnD;AAED,iBAAS,WAAW,CAAC,EACjB,SAAS,EACT,GAAG,KAAK,EACX,EAAE,cAAc,CAAC,OAAO,gBAAgB,CAAC,IAAI,CAAC,2CAmB9C;AAED,iBAAS,eAAe,CAAC,EACrB,SAAS,EACT,GAAG,KAAK,EACX,EAAE,cAAc,CAAC,MAAM,CAAC,2CAexB;AAED,OAAO,EACH,OAAO,EACP,aAAa,EACb,eAAe,EACf,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,eAAe,EACf,gBAAgB,GACnB,CAAC"}
|
|
@@ -16,7 +16,7 @@ declare function DropdownMenuPortal({ container, ...props }: ComponentProps<type
|
|
|
16
16
|
declare function DropdownMenuTrigger({ size, ...props }: ComponentProps<typeof MenuPrimitive.Trigger> & {
|
|
17
17
|
size?: DropdownMenuSize;
|
|
18
18
|
}): import("react/jsx-runtime").JSX.Element;
|
|
19
|
-
declare function DropdownMenuContent({ align, alignOffset, side, sideOffset, className, portalClassName, portalContainer, ...props }: MenuPrimitive.Popup.Props & Pick<MenuPrimitive.Positioner.Props, 'align' | 'alignOffset' | 'side' | 'sideOffset'> & {
|
|
19
|
+
declare function DropdownMenuContent({ align, alignOffset, side, sideOffset, positionMethod, className, portalClassName, portalContainer, ...props }: MenuPrimitive.Popup.Props & Pick<MenuPrimitive.Positioner.Props, 'align' | 'alignOffset' | 'side' | 'sideOffset' | 'positionMethod'> & {
|
|
20
20
|
portalClassName?: string;
|
|
21
21
|
portalContainer?: HTMLElement | ShadowRoot | null;
|
|
22
22
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DropdownMenu.d.ts","sourceRoot":"","sources":["../../src/components/DropdownMenu.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAA6B,MAAM,OAAO,CAAC;AAClE,OAAO,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CAAC,2CAOjD;AAED,iBAAS,qBAAqB,CAAC,EAC3B,SAAS,EACT,QAAQ,EACR,KAAK,EACL,GAAG,KAAK,EACX,EAAE,aAAa,CAAC,SAAS,CAAC,KAAK,GAAG;IAC/B,KAAK,CAAC,EAAE,OAAO,CAAA;CAClB,2CA0BA;AAED,iBAAS,qBAAqB,CAAC,EAC3B,SAAS,EACT,GAAG,KAAK,EACX,EAAE,aAAa,CAAC,SAAS,CAAC,KAAK,2CAa/B;AAED,iBAAS,oBAAoB,CAAC,EAC1B,SAAS,EACT,GAAG,KAAK,EACX,EAAE,cAAc,CAAC,MAAM,CAAC,2CAiBxB;AAED,OAAO,EACH,YAAY,EACZ,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,wBAAwB,EACxB,sBAAsB,EACtB,qBAAqB,EACrB,qBAAqB,EACrB,oBAAoB,EACpB,eAAe,EACf,sBAAsB,EACtB,sBAAsB,GACzB,CAAC"}
|
|
@@ -80,9 +80,10 @@ function DropdownMenuTrigger({ size, ...props }) {
|
|
|
80
80
|
...props
|
|
81
81
|
});
|
|
82
82
|
}
|
|
83
|
-
function DropdownMenuContent({ align = "start", alignOffset = 0, side = "bottom", sideOffset = 4, className, portalClassName, portalContainer, ...props }) {
|
|
83
|
+
function DropdownMenuContent({ align = "start", alignOffset = 0, side = "bottom", sideOffset = 4, positionMethod, className, portalClassName, portalContainer, ...props }) {
|
|
84
84
|
const resolvedPortalClassName = getPortalClassName(portalClassName);
|
|
85
85
|
const resolvedPortalContainer = getPortalContainer(portalContainer);
|
|
86
|
+
const resolvedPositionMethod = positionMethod ?? (resolvedPortalContainer instanceof ShadowRoot ? "fixed" : void 0);
|
|
86
87
|
return /* @__PURE__ */ jsx(Menu.Portal, {
|
|
87
88
|
className: resolvedPortalClassName,
|
|
88
89
|
container: resolvedPortalContainer,
|
|
@@ -91,6 +92,7 @@ function DropdownMenuContent({ align = "start", alignOffset = 0, side = "bottom"
|
|
|
91
92
|
alignOffset,
|
|
92
93
|
side,
|
|
93
94
|
sideOffset,
|
|
95
|
+
positionMethod: resolvedPositionMethod,
|
|
94
96
|
className: "z-[250]",
|
|
95
97
|
children: /* @__PURE__ */ jsx(Menu.Popup, {
|
|
96
98
|
"data-slot": "dropdown-menu-content",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DropdownMenu.js","names":[],"sources":["../../src/components/DropdownMenu.tsx"],"sourcesContent":["import { ComponentProps, createContext, useContext } from 'react';\nimport { Menu as MenuPrimitive } from '@base-ui/react/menu';\nimport { cva, type VariantProps } from 'class-variance-authority';\n\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome';\nimport { faCheck, faChevronRight } from '@fortawesome/pro-solid-svg-icons';\n\nimport { cn, getPortalClassName, getPortalContainer } from '@verbb/plugin-kit-react/utils';\n\nconst dropdownMenuItemVariants = cva([\n // Reset\n 'relative flex w-full cursor-default items-center outline-hidden select-none',\n\n // Focus\n 'focus:bg-slate-100 data-[highlighted]:bg-slate-100',\n\n // Disabled\n 'data-disabled:pointer-events-none data-disabled:opacity-50',\n\n // SVG — use single-quoted attribute selectors so Tailwind emits\n // svg:not([class*=size-]) rather than a broken escaped form.\n '[&_svg]:pointer-events-none [&_svg]:shrink-0',\n], {\n variants: {\n size: {\n xs: 'py-[3px] px-[8px] gap-1.5 text-[12px] [&_svg:not([class*=\\'size-\\'])]:size-2.5',\n sm: 'py-[4px] px-[10px] gap-1.75 text-[13px] [&_svg:not([class*=\\'size-\\'])]:size-3',\n default: 'py-[8px] px-[12px] gap-2.5 text-sm [&_svg:not([class*=\\'size-\\'])]:size-3',\n lg: 'py-[10px] px-[14px] gap-3 text-base [&_svg:not([class*=\\'size-\\'])]:size-3.5',\n xl: 'py-[12px] px-[16px] gap-3 text-lg [&_svg:not([class*=\\'size-\\'])]:size-4',\n },\n variant: {\n default: '',\n destructive: 'text-error',\n },\n },\n defaultVariants: {\n size: 'default',\n variant: 'default',\n },\n});\n\nconst dropdownMenuLabelVariants = cva([\n // Theme\n 'text-slate-700',\n], {\n variants: {\n size: {\n xs: 'py-[0px] px-[8px] text-[11px]',\n sm: 'py-[0px] px-[10px] text-[11px]',\n default: 'py-[0px] px-[12px] text-[13px]',\n lg: 'py-[0px] px-[14px] text-[14px]',\n xl: 'py-[0px] px-[16px] text-[15px]',\n },\n },\n defaultVariants: {\n size: 'default',\n },\n});\n\nconst dropdownMenuShortcutVariants = cva('', {\n variants: {\n size: {\n xs: 'text-[11px]',\n sm: 'text-xs',\n default: 'text-sm',\n lg: 'text-sm',\n xl: 'text-base',\n },\n },\n defaultVariants: {\n size: 'default',\n },\n});\n\ntype DropdownMenuSize = VariantProps<typeof dropdownMenuItemVariants>['size'];\n\nconst DropdownMenuContext = createContext<{ size?: DropdownMenuSize }>({});\n\nfunction DropdownMenu({\n size,\n children,\n ...props\n}: ComponentProps<typeof MenuPrimitive.Root> & { size?: DropdownMenuSize }) {\n return (\n <DropdownMenuContext.Provider value={{ size }}>\n <MenuPrimitive.Root data-slot=\"dropdown-menu\" {...props}>\n {children}\n </MenuPrimitive.Root>\n </DropdownMenuContext.Provider>\n );\n}\nfunction DropdownMenuPortal({\n container,\n ...props\n}: ComponentProps<typeof MenuPrimitive.Portal>) {\n const resolvedPortalContainer = getPortalContainer(container);\n\n return (\n <MenuPrimitive.Portal\n data-slot=\"dropdown-menu-portal\"\n container={resolvedPortalContainer}\n {...props}\n />\n );\n}\n\nfunction DropdownMenuTrigger({\n size,\n ...props\n}: ComponentProps<typeof MenuPrimitive.Trigger> & { size?: DropdownMenuSize }) {\n const context = useContext(DropdownMenuContext);\n const finalSize = size || context.size || 'default';\n\n return (\n <MenuPrimitive.Trigger\n data-slot=\"dropdown-menu-trigger\"\n data-size={finalSize}\n {...props}\n />\n );\n}\n\nfunction DropdownMenuContent({\n align = 'start',\n alignOffset = 0,\n side = 'bottom',\n sideOffset = 4,\n className,\n portalClassName,\n portalContainer,\n ...props\n}: MenuPrimitive.Popup.Props &\n Pick<\n MenuPrimitive.Positioner.Props,\n 'align' | 'alignOffset' | 'side' | 'sideOffset'\n > & {\n portalClassName?: string\n portalContainer?: HTMLElement | ShadowRoot | null\n }) {\n const resolvedPortalClassName = getPortalClassName(portalClassName);\n const resolvedPortalContainer = getPortalContainer(portalContainer);\n\n return (\n <MenuPrimitive.Portal className={resolvedPortalClassName} container={resolvedPortalContainer}>\n <MenuPrimitive.Positioner\n align={align}\n alignOffset={alignOffset}\n side={side}\n sideOffset={sideOffset}\n className=\"z-[250]\"\n >\n <MenuPrimitive.Popup\n data-slot=\"dropdown-menu-content\"\n className={cn(\n // Reset\n 'relative isolate z-[250] overflow-x-hidden overflow-y-auto',\n\n // Layout\n 'min-w-(--anchor-width)',\n // \"min-w-36 max-h-(--available-height) w-(--anchor-width)\",\n\n // Theme\n 'py-1',\n 'rounded-md bg-white',\n 'shadow-[0_0_0_1px_rgba(31,41,51,0.1),0_5px_20px_rgba(31,41,51,0.25)]',\n\n // Animation\n 'duration-100',\n 'data-open:animate-in data-closed:animate-out',\n 'data-open:fade-in-0 data-closed:fade-out-0',\n 'data-open:zoom-in-95 data-closed:zoom-out-95',\n 'data-[side=bottom]:slide-in-from-top-2',\n 'data-[side=top]:slide-in-from-bottom-2',\n 'data-[side=left]:slide-in-from-right-2',\n 'data-[side=right]:slide-in-from-left-2',\n 'data-[side=inline-start]:slide-in-from-right-2',\n 'data-[side=inline-end]:slide-in-from-left-2',\n 'data-[align-trigger=true]:animate-none',\n 'origin-(--transform-origin)',\n\n className,\n )}\n {...props}\n />\n </MenuPrimitive.Positioner>\n </MenuPrimitive.Portal>\n );\n};\n\nfunction DropdownMenuGroup({ ...props }: MenuPrimitive.Group.Props) {\n return <MenuPrimitive.Group data-slot=\"dropdown-menu-group\" {...props} />;\n}\n\nfunction DropdownMenuLabel({\n className,\n inset,\n size,\n ...props\n}: ComponentProps<typeof MenuPrimitive.GroupLabel> & VariantProps<typeof dropdownMenuLabelVariants> & {\n inset?: boolean\n}) {\n const context = useContext(DropdownMenuContext);\n const finalSize = size || context.size || 'default';\n\n return (\n <MenuPrimitive.GroupLabel\n data-slot=\"dropdown-menu-label\"\n data-inset={inset}\n data-size={finalSize}\n className={cn(\n dropdownMenuLabelVariants({ size: finalSize, className }),\n )}\n {...props}\n />\n );\n};\n\nfunction DropdownMenuItem({\n className,\n inset,\n size,\n variant = 'default',\n ...props\n}: ComponentProps<typeof MenuPrimitive.Item> & VariantProps<typeof dropdownMenuItemVariants> & {\n inset?: boolean\n variant?: 'default' | 'destructive'\n}) {\n const context = useContext(DropdownMenuContext);\n const finalSize = size || context.size || 'default';\n\n return (\n <MenuPrimitive.Item\n data-slot=\"dropdown-menu-item\"\n data-inset={inset}\n data-variant={variant}\n data-size={finalSize}\n className={cn(\n dropdownMenuItemVariants({ size: finalSize, variant, className }),\n\n inset && 'pl-8',\n )}\n {...props}\n />\n );\n};\n\nfunction DropdownMenuSub({\n ...props\n}: ComponentProps<typeof MenuPrimitive.SubmenuRoot>) {\n return <MenuPrimitive.SubmenuRoot data-slot=\"dropdown-menu-sub\" {...props} />;\n}\n\nfunction DropdownMenuSubTrigger({\n className,\n inset,\n children,\n size,\n ...props\n}: ComponentProps<typeof MenuPrimitive.SubmenuTrigger> & {\n inset?: boolean\n size?: DropdownMenuSize\n}) {\n const context = useContext(DropdownMenuContext);\n const finalSize = size || context.size || 'default';\n\n return (\n <MenuPrimitive.SubmenuTrigger\n data-slot=\"dropdown-menu-sub-trigger\"\n data-inset={inset}\n data-size={finalSize}\n className={cn(\n dropdownMenuItemVariants({ size: finalSize }),\n\n // Keep submenu triggers visually active while their child menu is open\n 'data-[popup-open]:bg-slate-100',\n\n // SVG\n '[&_svg]:pointer-events-none [&_svg]:shrink-0',\n\n inset && 'pl-8',\n\n className,\n )}\n {...props}\n >\n {children}\n <FontAwesomeIcon icon={faChevronRight} className=\"ml-auto size-3 text-slate-700\" />\n </MenuPrimitive.SubmenuTrigger>\n );\n};\n\nfunction DropdownMenuSubContent({\n align = 'start',\n alignOffset = -3,\n side = 'right',\n sideOffset = 0,\n className,\n ...props\n}: ComponentProps<typeof DropdownMenuContent>) {\n\n return (\n <DropdownMenuContent\n data-slot=\"dropdown-menu-sub-content\"\n className={cn(\n 'min-w-32 w-auto',\n className,\n )}\n align={align}\n alignOffset={alignOffset}\n side={side}\n sideOffset={sideOffset}\n {...props}\n />\n );\n};\n\nfunction DropdownMenuCheckboxItem({\n className,\n children,\n checked,\n inset,\n ...props\n}: MenuPrimitive.CheckboxItem.Props & {\n inset?: boolean\n}) {\n const context = useContext(DropdownMenuContext);\n const finalSize = context?.size || 'default';\n\n return (\n <MenuPrimitive.CheckboxItem\n data-slot=\"dropdown-menu-checkbox-item\"\n data-inset={inset}\n className={cn(\n dropdownMenuItemVariants({ size: finalSize, className }),\n )}\n checked={checked}\n {...props}\n >\n {children}\n <span\n data-slot=\"dropdown-menu-checkbox-item-indicator\"\n className={cn(\n 'ml-auto pl-4',\n )}\n >\n <MenuPrimitive.CheckboxItemIndicator>\n <FontAwesomeIcon icon={faCheck} className={cn('size-3')} />\n </MenuPrimitive.CheckboxItemIndicator>\n </span>\n </MenuPrimitive.CheckboxItem>\n );\n};\n\nfunction DropdownMenuRadioGroup({\n ...props\n}: ComponentProps<typeof MenuPrimitive.RadioGroup>) {\n return (\n <MenuPrimitive.RadioGroup\n data-slot=\"dropdown-menu-radio-group\"\n {...props}\n />\n );\n}\n\nfunction DropdownMenuRadioItem({\n className,\n children,\n inset,\n ...props\n}: MenuPrimitive.RadioItem.Props & {\n inset?: boolean\n}) {\n const context = useContext(DropdownMenuContext);\n const finalSize = context?.size || 'default';\n\n return (\n <MenuPrimitive.RadioItem\n data-slot=\"dropdown-menu-radio-item\"\n data-inset={inset}\n className={cn(\n dropdownMenuItemVariants({ size: finalSize, className }),\n )}\n {...props}\n >\n {children}\n <span\n data-slot=\"dropdown-menu-radio-item-indicator\"\n className={cn(\n 'ml-auto pl-4',\n )}\n >\n <MenuPrimitive.RadioItemIndicator>\n <FontAwesomeIcon icon={faCheck} className={cn('size-3')} />\n </MenuPrimitive.RadioItemIndicator>\n </span>\n </MenuPrimitive.RadioItem>\n );\n};\n\nfunction DropdownMenuSeparator({\n className,\n ...props\n}: MenuPrimitive.Separator.Props) {\n return (\n <MenuPrimitive.Separator\n data-slot=\"dropdown-menu-separator\"\n className={cn(\n // Theme\n 'my-1 h-px bg-slate-200',\n\n className,\n )}\n {...props}\n />\n );\n};\n\nfunction DropdownMenuShortcut({\n className,\n ...props\n}: ComponentProps<'span'>) {\n const context = useContext(DropdownMenuContext);\n const finalSize = context?.size || 'default';\n\n return (\n <span\n data-slot=\"dropdown-menu-shortcut\"\n className={cn(\n 'text-slate-700 group-focus/dropdown-menu-item:text-slate-700 ml-auto tracking-widest',\n\n dropdownMenuShortcutVariants({ size: finalSize, className }),\n\n className,\n )}\n {...props}\n />\n );\n};\n\nexport {\n DropdownMenu,\n DropdownMenuPortal,\n DropdownMenuTrigger,\n DropdownMenuContent,\n DropdownMenuGroup,\n DropdownMenuLabel,\n DropdownMenuItem,\n DropdownMenuCheckboxItem,\n DropdownMenuRadioGroup,\n DropdownMenuRadioItem,\n DropdownMenuSeparator,\n DropdownMenuShortcut,\n DropdownMenuSub,\n DropdownMenuSubTrigger,\n DropdownMenuSubContent,\n};\n"],"mappings":";;;;;;;;;;AASA,IAAM,2BAA2B,IAAI;CAEjC;CAGA;CAGA;CAIA;CACH,EAAE;CACC,UAAU;EACN,MAAM;GACF,IAAI;GACJ,IAAI;GACJ,SAAS;GACT,IAAI;GACJ,IAAI;GACP;EACD,SAAS;GACL,SAAS;GACT,aAAa;GAChB;EACJ;CACD,iBAAiB;EACb,MAAM;EACN,SAAS;EACZ;CACJ,CAAC;AAEF,IAAM,4BAA4B,IAAI,CAElC,iBACH,EAAE;CACC,UAAU,EACN,MAAM;EACF,IAAI;EACJ,IAAI;EACJ,SAAS;EACT,IAAI;EACJ,IAAI;EACP,EACJ;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f;EACI,aAAU;EACV,WAAW,GAEP,0BAEA,UACH;EACD,GAAI;EACN,CAAA;;AAIV,SAAS,qBAAqB,EAC1B,WACA,GAAG,SACoB;AAIvB,QACI,oBAAC,QAAD;EACI,aAAU;EACV,WAAW,GACP,wFAEA,6BAA6B;GAAE,MAT3B,WAAW,oBACT,EAAS,QAAQ;GAQyB;GAAW,CAAC,EAE5D,UACH;EACD,GAAI;EACN,CAAA"}
|
|
1
|
+
{"version":3,"file":"DropdownMenu.js","names":[],"sources":["../../src/components/DropdownMenu.tsx"],"sourcesContent":["import { ComponentProps, createContext, useContext } from 'react';\nimport { Menu as MenuPrimitive } from '@base-ui/react/menu';\nimport { cva, type VariantProps } from 'class-variance-authority';\n\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome';\nimport { faCheck, faChevronRight } from '@fortawesome/pro-solid-svg-icons';\n\nimport { cn, getPortalClassName, getPortalContainer } from '@verbb/plugin-kit-react/utils';\n\nconst dropdownMenuItemVariants = cva([\n // Reset\n 'relative flex w-full cursor-default items-center outline-hidden select-none',\n\n // Focus\n 'focus:bg-slate-100 data-[highlighted]:bg-slate-100',\n\n // Disabled\n 'data-disabled:pointer-events-none data-disabled:opacity-50',\n\n // SVG — use single-quoted attribute selectors so Tailwind emits\n // svg:not([class*=size-]) rather than a broken escaped form.\n '[&_svg]:pointer-events-none [&_svg]:shrink-0',\n], {\n variants: {\n size: {\n xs: 'py-[3px] px-[8px] gap-1.5 text-[12px] [&_svg:not([class*=\\'size-\\'])]:size-2.5',\n sm: 'py-[4px] px-[10px] gap-1.75 text-[13px] [&_svg:not([class*=\\'size-\\'])]:size-3',\n default: 'py-[8px] px-[12px] gap-2.5 text-sm [&_svg:not([class*=\\'size-\\'])]:size-3',\n lg: 'py-[10px] px-[14px] gap-3 text-base [&_svg:not([class*=\\'size-\\'])]:size-3.5',\n xl: 'py-[12px] px-[16px] gap-3 text-lg [&_svg:not([class*=\\'size-\\'])]:size-4',\n },\n variant: {\n default: '',\n destructive: 'text-error',\n },\n },\n defaultVariants: {\n size: 'default',\n variant: 'default',\n },\n});\n\nconst dropdownMenuLabelVariants = cva([\n // Theme\n 'text-slate-700',\n], {\n variants: {\n size: {\n xs: 'py-[0px] px-[8px] text-[11px]',\n sm: 'py-[0px] px-[10px] text-[11px]',\n default: 'py-[0px] px-[12px] text-[13px]',\n lg: 'py-[0px] px-[14px] text-[14px]',\n xl: 'py-[0px] px-[16px] text-[15px]',\n },\n },\n defaultVariants: {\n size: 'default',\n },\n});\n\nconst dropdownMenuShortcutVariants = cva('', {\n variants: {\n size: {\n xs: 'text-[11px]',\n sm: 'text-xs',\n default: 'text-sm',\n lg: 'text-sm',\n xl: 'text-base',\n },\n },\n defaultVariants: {\n size: 'default',\n },\n});\n\ntype DropdownMenuSize = VariantProps<typeof dropdownMenuItemVariants>['size'];\n\nconst DropdownMenuContext = createContext<{ size?: DropdownMenuSize }>({});\n\nfunction DropdownMenu({\n size,\n children,\n ...props\n}: ComponentProps<typeof MenuPrimitive.Root> & { size?: DropdownMenuSize }) {\n return (\n <DropdownMenuContext.Provider value={{ size }}>\n <MenuPrimitive.Root data-slot=\"dropdown-menu\" {...props}>\n {children}\n </MenuPrimitive.Root>\n </DropdownMenuContext.Provider>\n );\n}\nfunction DropdownMenuPortal({\n container,\n ...props\n}: ComponentProps<typeof MenuPrimitive.Portal>) {\n const resolvedPortalContainer = getPortalContainer(container);\n\n return (\n <MenuPrimitive.Portal\n data-slot=\"dropdown-menu-portal\"\n container={resolvedPortalContainer}\n {...props}\n />\n );\n}\n\nfunction DropdownMenuTrigger({\n size,\n ...props\n}: ComponentProps<typeof MenuPrimitive.Trigger> & { size?: DropdownMenuSize }) {\n const context = useContext(DropdownMenuContext);\n const finalSize = size || context.size || 'default';\n\n return (\n <MenuPrimitive.Trigger\n data-slot=\"dropdown-menu-trigger\"\n data-size={finalSize}\n {...props}\n />\n );\n}\n\nfunction DropdownMenuContent({\n align = 'start',\n alignOffset = 0,\n side = 'bottom',\n sideOffset = 4,\n positionMethod,\n className,\n portalClassName,\n portalContainer,\n ...props\n}: MenuPrimitive.Popup.Props &\n Pick<\n MenuPrimitive.Positioner.Props,\n 'align' | 'alignOffset' | 'side' | 'sideOffset' | 'positionMethod'\n > & {\n portalClassName?: string\n portalContainer?: HTMLElement | ShadowRoot | null\n }) {\n const resolvedPortalClassName = getPortalClassName(portalClassName);\n const resolvedPortalContainer = getPortalContainer(portalContainer);\n const resolvedPositionMethod = positionMethod ?? (\n resolvedPortalContainer instanceof ShadowRoot ? 'fixed' : undefined\n );\n\n return (\n <MenuPrimitive.Portal className={resolvedPortalClassName} container={resolvedPortalContainer}>\n <MenuPrimitive.Positioner\n align={align}\n alignOffset={alignOffset}\n side={side}\n sideOffset={sideOffset}\n positionMethod={resolvedPositionMethod}\n className=\"z-[250]\"\n >\n <MenuPrimitive.Popup\n data-slot=\"dropdown-menu-content\"\n className={cn(\n // Reset\n 'relative isolate z-[250] overflow-x-hidden overflow-y-auto',\n\n // Layout\n 'min-w-(--anchor-width)',\n // \"min-w-36 max-h-(--available-height) w-(--anchor-width)\",\n\n // Theme\n 'py-1',\n 'rounded-md bg-white',\n 'shadow-[0_0_0_1px_rgba(31,41,51,0.1),0_5px_20px_rgba(31,41,51,0.25)]',\n\n // Animation\n 'duration-100',\n 'data-open:animate-in data-closed:animate-out',\n 'data-open:fade-in-0 data-closed:fade-out-0',\n 'data-open:zoom-in-95 data-closed:zoom-out-95',\n 'data-[side=bottom]:slide-in-from-top-2',\n 'data-[side=top]:slide-in-from-bottom-2',\n 'data-[side=left]:slide-in-from-right-2',\n 'data-[side=right]:slide-in-from-left-2',\n 'data-[side=inline-start]:slide-in-from-right-2',\n 'data-[side=inline-end]:slide-in-from-left-2',\n 'data-[align-trigger=true]:animate-none',\n 'origin-(--transform-origin)',\n\n className,\n )}\n {...props}\n />\n </MenuPrimitive.Positioner>\n </MenuPrimitive.Portal>\n );\n};\n\nfunction DropdownMenuGroup({ ...props }: MenuPrimitive.Group.Props) {\n return <MenuPrimitive.Group data-slot=\"dropdown-menu-group\" {...props} />;\n}\n\nfunction DropdownMenuLabel({\n className,\n inset,\n size,\n ...props\n}: ComponentProps<typeof MenuPrimitive.GroupLabel> & VariantProps<typeof dropdownMenuLabelVariants> & {\n inset?: boolean\n}) {\n const context = useContext(DropdownMenuContext);\n const finalSize = size || context.size || 'default';\n\n return (\n <MenuPrimitive.GroupLabel\n data-slot=\"dropdown-menu-label\"\n data-inset={inset}\n data-size={finalSize}\n className={cn(\n dropdownMenuLabelVariants({ size: finalSize, className }),\n )}\n {...props}\n />\n );\n};\n\nfunction DropdownMenuItem({\n className,\n inset,\n size,\n variant = 'default',\n ...props\n}: ComponentProps<typeof MenuPrimitive.Item> & VariantProps<typeof dropdownMenuItemVariants> & {\n inset?: boolean\n variant?: 'default' | 'destructive'\n}) {\n const context = useContext(DropdownMenuContext);\n const finalSize = size || context.size || 'default';\n\n return (\n <MenuPrimitive.Item\n data-slot=\"dropdown-menu-item\"\n data-inset={inset}\n data-variant={variant}\n data-size={finalSize}\n className={cn(\n dropdownMenuItemVariants({ size: finalSize, variant, className }),\n\n inset && 'pl-8',\n )}\n {...props}\n />\n );\n};\n\nfunction DropdownMenuSub({\n ...props\n}: ComponentProps<typeof MenuPrimitive.SubmenuRoot>) {\n return <MenuPrimitive.SubmenuRoot data-slot=\"dropdown-menu-sub\" {...props} />;\n}\n\nfunction DropdownMenuSubTrigger({\n className,\n inset,\n children,\n size,\n ...props\n}: ComponentProps<typeof MenuPrimitive.SubmenuTrigger> & {\n inset?: boolean\n size?: DropdownMenuSize\n}) {\n const context = useContext(DropdownMenuContext);\n const finalSize = size || context.size || 'default';\n\n return (\n <MenuPrimitive.SubmenuTrigger\n data-slot=\"dropdown-menu-sub-trigger\"\n data-inset={inset}\n data-size={finalSize}\n className={cn(\n dropdownMenuItemVariants({ size: finalSize }),\n\n // Keep submenu triggers visually active while their child menu is open\n 'data-[popup-open]:bg-slate-100',\n\n // SVG\n '[&_svg]:pointer-events-none [&_svg]:shrink-0',\n\n inset && 'pl-8',\n\n className,\n )}\n {...props}\n >\n {children}\n <FontAwesomeIcon icon={faChevronRight} className=\"ml-auto size-3 text-slate-700\" />\n </MenuPrimitive.SubmenuTrigger>\n );\n};\n\nfunction DropdownMenuSubContent({\n align = 'start',\n alignOffset = -3,\n side = 'right',\n sideOffset = 0,\n className,\n ...props\n}: ComponentProps<typeof DropdownMenuContent>) {\n\n return (\n <DropdownMenuContent\n data-slot=\"dropdown-menu-sub-content\"\n className={cn(\n 'min-w-32 w-auto',\n className,\n )}\n align={align}\n alignOffset={alignOffset}\n side={side}\n sideOffset={sideOffset}\n {...props}\n />\n );\n};\n\nfunction DropdownMenuCheckboxItem({\n className,\n children,\n checked,\n inset,\n ...props\n}: MenuPrimitive.CheckboxItem.Props & {\n inset?: boolean\n}) {\n const context = useContext(DropdownMenuContext);\n const finalSize = context?.size || 'default';\n\n return (\n <MenuPrimitive.CheckboxItem\n data-slot=\"dropdown-menu-checkbox-item\"\n data-inset={inset}\n className={cn(\n dropdownMenuItemVariants({ size: finalSize, className }),\n )}\n checked={checked}\n {...props}\n >\n {children}\n <span\n data-slot=\"dropdown-menu-checkbox-item-indicator\"\n className={cn(\n 'ml-auto pl-4',\n )}\n >\n <MenuPrimitive.CheckboxItemIndicator>\n <FontAwesomeIcon icon={faCheck} className={cn('size-3')} />\n </MenuPrimitive.CheckboxItemIndicator>\n </span>\n </MenuPrimitive.CheckboxItem>\n );\n};\n\nfunction DropdownMenuRadioGroup({\n ...props\n}: ComponentProps<typeof MenuPrimitive.RadioGroup>) {\n return (\n <MenuPrimitive.RadioGroup\n data-slot=\"dropdown-menu-radio-group\"\n {...props}\n />\n );\n}\n\nfunction DropdownMenuRadioItem({\n className,\n children,\n inset,\n ...props\n}: MenuPrimitive.RadioItem.Props & {\n inset?: boolean\n}) {\n const context = useContext(DropdownMenuContext);\n const finalSize = context?.size || 'default';\n\n return (\n <MenuPrimitive.RadioItem\n data-slot=\"dropdown-menu-radio-item\"\n data-inset={inset}\n className={cn(\n dropdownMenuItemVariants({ size: finalSize, className }),\n )}\n {...props}\n >\n {children}\n <span\n data-slot=\"dropdown-menu-radio-item-indicator\"\n className={cn(\n 'ml-auto pl-4',\n )}\n >\n <MenuPrimitive.RadioItemIndicator>\n <FontAwesomeIcon icon={faCheck} className={cn('size-3')} />\n </MenuPrimitive.RadioItemIndicator>\n </span>\n </MenuPrimitive.RadioItem>\n );\n};\n\nfunction DropdownMenuSeparator({\n className,\n ...props\n}: MenuPrimitive.Separator.Props) {\n return (\n <MenuPrimitive.Separator\n data-slot=\"dropdown-menu-separator\"\n className={cn(\n // Theme\n 'my-1 h-px bg-slate-200',\n\n className,\n )}\n {...props}\n />\n );\n};\n\nfunction DropdownMenuShortcut({\n className,\n ...props\n}: ComponentProps<'span'>) {\n const context = useContext(DropdownMenuContext);\n const finalSize = context?.size || 'default';\n\n return (\n <span\n data-slot=\"dropdown-menu-shortcut\"\n className={cn(\n 'text-slate-700 group-focus/dropdown-menu-item:text-slate-700 ml-auto tracking-widest',\n\n dropdownMenuShortcutVariants({ size: finalSize, className }),\n\n className,\n )}\n {...props}\n />\n );\n};\n\nexport {\n DropdownMenu,\n DropdownMenuPortal,\n DropdownMenuTrigger,\n DropdownMenuContent,\n DropdownMenuGroup,\n DropdownMenuLabel,\n DropdownMenuItem,\n DropdownMenuCheckboxItem,\n DropdownMenuRadioGroup,\n DropdownMenuRadioItem,\n DropdownMenuSeparator,\n DropdownMenuShortcut,\n DropdownMenuSub,\n DropdownMenuSubTrigger,\n DropdownMenuSubContent,\n};\n"],"mappings":";;;;;;;;;;AASA,IAAM,2BAA2B,IAAI;CAEjC;CAGA;CAGA;CAIA;CACH,EAAE;CACC,UAAU;EACN,MAAM;GACF,IAAI;GACJ,IAAI;GACJ,SAAS;GACT,IAAI;GACJ,IAAI;GACP;EACD,SAAS;GACL,SAAS;GACT,aAAa;GAChB;EACJ;CACD,iBAAiB;EACb,MAAM;EACN,SAAS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;GACV,WAAW,GACP,eACH;aAED,oBAAC,KAAc,oBAAf,EAAA,UACI,oBAAC,iBAAD;IAAiB,MAAM;IAAS,WAAW,GAAG,SAAS;IAAI,CAAA,EAC5B,CAAA;GAChC,CAAA,CACe;;;AAIlC,SAAS,sBAAsB,EAC3B,WACA,GAAG,SAC2B;AAC9B,QACI,oBAAC,KAAc,WAAf;EACI,aAAU;EACV,WAAW,GAEP,0BAEA,UACH;EACD,GAAI;EACN,CAAA;;AAIV,SAAS,qBAAqB,EAC1B,WACA,GAAG,SACoB;AAIvB,QACI,oBAAC,QAAD;EACI,aAAU;EACV,WAAW,GACP,wFAEA,6BAA6B;GAAE,MAT3B,WAAW,oBACT,EAAS,QAAQ;GAQyB;GAAW,CAAC,EAE5D,UACH;EACD,GAAI;EACN,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PaneTabs.d.ts","sourceRoot":"","sources":["../../src/components/PaneTabs.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAAE,IAAI,IAAI,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAI5D,iBAAS,QAAQ,CAAC,EACd,SAAS,EACT,GAAG,KAAK,EACX,EAAE,cAAc,CAAC,OAAO,aAAa,CAAC,IAAI,CAAC,2CAgB3C;AAED,iBAAS,YAAY,CAAC,EAClB,SAAS,EACT,GAAG,KAAK,EACX,EAAE,cAAc,CAAC,OAAO,aAAa,CAAC,IAAI,CAAC,2CAiB3C;AAED,iBAAS,eAAe,CAAC,EACrB,SAAS,EACT,GAAG,KAAK,EACX,EAAE,cAAc,CAAC,OAAO,aAAa,CAAC,GAAG,CAAC,2CAwB1C;AAED,iBAAS,eAAe,CAAC,EACrB,SAAS,EACT,GAAG,KAAK,EACX,EAAE,cAAc,CAAC,OAAO,aAAa,CAAC,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"PaneTabs.d.ts","sourceRoot":"","sources":["../../src/components/PaneTabs.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAAE,IAAI,IAAI,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAI5D,iBAAS,QAAQ,CAAC,EACd,SAAS,EACT,GAAG,KAAK,EACX,EAAE,cAAc,CAAC,OAAO,aAAa,CAAC,IAAI,CAAC,2CAgB3C;AAED,iBAAS,YAAY,CAAC,EAClB,SAAS,EACT,GAAG,KAAK,EACX,EAAE,cAAc,CAAC,OAAO,aAAa,CAAC,IAAI,CAAC,2CAiB3C;AAED,iBAAS,eAAe,CAAC,EACrB,SAAS,EACT,GAAG,KAAK,EACX,EAAE,cAAc,CAAC,OAAO,aAAa,CAAC,GAAG,CAAC,2CAwB1C;AAED,iBAAS,eAAe,CAAC,EACrB,SAAS,EACT,GAAG,KAAK,EACX,EAAE,cAAc,CAAC,OAAO,aAAa,CAAC,KAAK,CAAC,2CAkB5C;AAED,OAAO,EACH,QAAQ,EACR,YAAY,EACZ,eAAe,EACf,eAAe,GAClB,CAAC"}
|
|
@@ -27,7 +27,7 @@ function PaneTabsTrigger({ className, ...props }) {
|
|
|
27
27
|
function PaneTabsContent({ className, ...props }) {
|
|
28
28
|
return /* @__PURE__ */ jsx(Tabs.Panel, {
|
|
29
29
|
"data-slot": "tabs-content",
|
|
30
|
-
className: cn("outline-none", "relative", "h-full", "overflow-y-auto", "bg-white rounded-b-lg",
|
|
30
|
+
className: cn("outline-none", "relative", "h-full", "overflow-y-auto", "bg-white rounded-b-lg", className),
|
|
31
31
|
...props
|
|
32
32
|
});
|
|
33
33
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PaneTabs.js","names":[],"sources":["../../src/components/PaneTabs.tsx"],"sourcesContent":["import { ComponentProps } from 'react';\nimport { Tabs as TabsPrimitive } from '@base-ui/react/tabs';\n\nimport { cn } from '@verbb/plugin-kit-react/utils';\n\nfunction PaneTabs({\n className,\n ...props\n}: ComponentProps<typeof TabsPrimitive.Root>) {\n return (\n <TabsPrimitive.Root\n data-slot=\"tabs\"\n className={cn(\n // Reset and layout\n 'flex flex-col h-full',\n\n 'rounded-lg',\n 'shadow-[0_0_0_1px_var(--color-gray-200),_0_2px_12px_rgb(205_216_228_/_50%)]',\n\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction PaneTabsList({\n className,\n ...props\n}: ComponentProps<typeof TabsPrimitive.List>) {\n return (\n <TabsPrimitive.List\n data-slot=\"tabs-list\"\n className={cn(\n // Reset and layout\n 'flex',\n\n 'shadow-[inset_0_-1px_0_0_rgba(154,165,177,0.25)]',\n\n 'bg-gray-50 rounded-t-lg',\n\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction PaneTabsTrigger({\n className,\n ...props\n}: ComponentProps<typeof TabsPrimitive.Tab>) {\n return (\n <TabsPrimitive.Tab\n data-slot=\"tabs-trigger\"\n className={cn(\n // Reset and layout\n 'flex items-center cursor-pointer outline-none whitespace-nowrap',\n\n 'h-[45px] px-[24px] text-gray-550',\n\n // Hover state\n 'hover:bg-slate-100',\n\n // Accessibility\n 'focus-visible:shadow-[inset_0_0_0_2px_var(--color-sky-600)]',\n\n // Active state\n 'data-[active]:rounded-t-xs data-[active]:relative data-[active]:bg-white data-[active]:hover:bg-white data-[active]:text-gray-700 data-[active]:shadow-[inset_0_2px_0_rgb(107,114,128),0_0_0_1px_rgba(51,64,77,0.1),0_2px_12px_rgba(205,216,228,0.9)]',\n\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction PaneTabsContent({\n className,\n ...props\n}: ComponentProps<typeof TabsPrimitive.Panel>) {\n return (\n <TabsPrimitive.Panel\n data-slot=\"tabs-content\"\n className={cn(\n // Reset and layout\n 'outline-none',\n 'relative',\n 'h-full',\n\n 'overflow-y-auto',\n 'bg-white rounded-b-lg',\n\n
|
|
1
|
+
{"version":3,"file":"PaneTabs.js","names":[],"sources":["../../src/components/PaneTabs.tsx"],"sourcesContent":["import { ComponentProps } from 'react';\nimport { Tabs as TabsPrimitive } from '@base-ui/react/tabs';\n\nimport { cn } from '@verbb/plugin-kit-react/utils';\n\nfunction PaneTabs({\n className,\n ...props\n}: ComponentProps<typeof TabsPrimitive.Root>) {\n return (\n <TabsPrimitive.Root\n data-slot=\"tabs\"\n className={cn(\n // Reset and layout\n 'flex flex-col h-full',\n\n 'rounded-lg',\n 'shadow-[0_0_0_1px_var(--color-gray-200),_0_2px_12px_rgb(205_216_228_/_50%)]',\n\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction PaneTabsList({\n className,\n ...props\n}: ComponentProps<typeof TabsPrimitive.List>) {\n return (\n <TabsPrimitive.List\n data-slot=\"tabs-list\"\n className={cn(\n // Reset and layout\n 'flex',\n\n 'shadow-[inset_0_-1px_0_0_rgba(154,165,177,0.25)]',\n\n 'bg-gray-50 rounded-t-lg',\n\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction PaneTabsTrigger({\n className,\n ...props\n}: ComponentProps<typeof TabsPrimitive.Tab>) {\n return (\n <TabsPrimitive.Tab\n data-slot=\"tabs-trigger\"\n className={cn(\n // Reset and layout\n 'flex items-center cursor-pointer outline-none whitespace-nowrap',\n\n 'h-[45px] px-[24px] text-gray-550',\n\n // Hover state\n 'hover:bg-slate-100',\n\n // Accessibility\n 'focus-visible:shadow-[inset_0_0_0_2px_var(--color-sky-600)]',\n\n // Active state\n 'data-[active]:rounded-t-xs data-[active]:relative data-[active]:bg-white data-[active]:hover:bg-white data-[active]:text-gray-700 data-[active]:shadow-[inset_0_2px_0_rgb(107,114,128),0_0_0_1px_rgba(51,64,77,0.1),0_2px_12px_rgba(205,216,228,0.9)]',\n\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction PaneTabsContent({\n className,\n ...props\n}: ComponentProps<typeof TabsPrimitive.Panel>) {\n return (\n <TabsPrimitive.Panel\n data-slot=\"tabs-content\"\n className={cn(\n // Reset and layout\n 'outline-none',\n 'relative',\n 'h-full',\n\n 'overflow-y-auto',\n 'bg-white rounded-b-lg',\n\n className,\n )}\n {...props}\n />\n );\n}\n\nexport {\n PaneTabs,\n PaneTabsList,\n PaneTabsTrigger,\n PaneTabsContent,\n};\n"],"mappings":";;;;;AAKA,SAAS,SAAS,EACd,WACA,GAAG,SACuC;AAC1C,QACI,oBAAC,KAAc,MAAf;EACI,aAAU;EACV,WAAW,GAEP,wBAEA,cACA,+EAEA,UACH;EACD,GAAI;EACN,CAAA;;AAIV,SAAS,aAAa,EAClB,WACA,GAAG,SACuC;AAC1C,QACI,oBAAC,KAAc,MAAf;EACI,aAAU;EACV,WAAW,GAEP,QAEA,oDAEA,2BAEA,UACH;EACD,GAAI;EACN,CAAA;;AAIV,SAAS,gBAAgB,EACrB,WACA,GAAG,SACsC;AACzC,QACI,oBAAC,KAAc,KAAf;EACI,aAAU;EACV,WAAW,GAEP,mEAEA,oCAGA,sBAGA,+DAGA,yPAEA,UACH;EACD,GAAI;EACN,CAAA;;AAIV,SAAS,gBAAgB,EACrB,WACA,GAAG,SACwC;AAC3C,QACI,oBAAC,KAAc,OAAf;EACI,aAAU;EACV,WAAW,GAEP,gBACA,YACA,UAEA,mBACA,yBAEA,UACH;EACD,GAAI;EACN,CAAA"}
|
package/dist/forms/Field.d.ts
CHANGED
|
@@ -31,7 +31,8 @@ type FieldLayoutProps = ComponentProps<'div'> & {
|
|
|
31
31
|
errors?: string[];
|
|
32
32
|
withControl?: boolean;
|
|
33
33
|
showInlineErrors?: boolean;
|
|
34
|
+
translatable?: boolean;
|
|
34
35
|
};
|
|
35
|
-
declare const FieldLayout: ({ name, label, instructions, headerEnd, required, warning, errors, withControl, showInlineErrors, className, children, ...props }: FieldLayoutProps) => import("react/jsx-runtime").JSX.Element;
|
|
36
|
+
declare const FieldLayout: ({ name, label, instructions, headerEnd, required, warning, errors, withControl, showInlineErrors, translatable, className, children, ...props }: FieldLayoutProps) => import("react/jsx-runtime").JSX.Element;
|
|
36
37
|
export { FieldRoot, FieldHeader, FieldLabel, FieldInstructions, FieldControl, FieldErrors, FieldLayout, InlineFieldErrorVisibilityContext, useFieldContext, };
|
|
37
38
|
//# sourceMappingURL=Field.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Field.d.ts","sourceRoot":"","sources":["../../src/forms/Field.tsx"],"names":[],"mappings":"AAAA,OAAO,EAC+B,KAAK,cAAc,EAAE,KAAK,SAAS,EACxE,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,KAAK,EAAY,MAAM,oCAAoC,CAAC;AACrE,OAAO,EAAE,IAAI,EAAE,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"Field.d.ts","sourceRoot":"","sources":["../../src/forms/Field.tsx"],"names":[],"mappings":"AAAA,OAAO,EAC+B,KAAK,cAAc,EAAE,KAAK,SAAS,EACxE,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,KAAK,EAAY,MAAM,oCAAoC,CAAC;AACrE,OAAO,EAAE,IAAI,EAAE,MAAM,yCAAyC,CAAC;AAQ/D,KAAK,iBAAiB,GAAG;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,EAAE,CAAC;CACpB,CAAC;AAGF,QAAA,MAAM,iCAAiC,kCAA+B,CAAC;AAEvE,QAAA,MAAM,eAAe,yBAMpB,CAAC;AAEF,KAAK,cAAc,GAAG,cAAc,CAAC,KAAK,CAAC,GAAG;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC;AAEF,QAAA,MAAM,SAAS,GAAI,uCAEhB,cAAc,4CAWhB,CAAC;AAEF,QAAA,MAAM,WAAW,GAAI,yBAAyB,cAAc,CAAC,KAAK,CAAC,4CAIlE,CAAC;AAEF,QAAA,MAAM,UAAU,GAAI,yBAAyB,cAAc,CAAC,OAAO,KAAK,CAAC,4CAWxE,CAAC;AAEF,QAAA,MAAM,iBAAiB,GAAI,mCAAmC,cAAc,CAAC,GAAG,CAAC,4CA0BhF,CAAC;AAEF,KAAK,iBAAiB,GAAG,IAAI,CAAC,cAAc,CAAC,OAAO,IAAI,CAAC,EAAE,WAAW,CAAC,GAAG;IACtE,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,QAAA,MAAM,YAAY,GAAI,yBAAyB,iBAAiB,4CAe/D,CAAC;AAEF,QAAA,MAAM,WAAW,GAAI,yBAAyB,cAAc,CAAC,IAAI,CAAC,mDAsBjE,CAAC;AAEF,KAAK,gBAAgB,GAAG,cAAc,CAAC,KAAK,CAAC,GAAG;IAC5C,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,YAAY,CAAC,EAAE,OAAO,CAAC;CAC1B,CAAC;AAEF,QAAA,MAAM,WAAW,GAAI,iJAclB,gBAAgB,4CAqElB,CAAC;AAEF,OAAO,EACH,SAAS,EACT,WAAW,EACX,UAAU,EACV,iBAAiB,EACjB,YAAY,EACZ,WAAW,EACX,WAAW,EACX,iCAAiC,EACjC,eAAe,GAClB,CAAC"}
|
package/dist/forms/Field.js
CHANGED
|
@@ -6,6 +6,7 @@ import { Label } from "../components/Label.js";
|
|
|
6
6
|
import { Markdown } from "../components/Markdown.js";
|
|
7
7
|
import "../components/index.js";
|
|
8
8
|
import { Slot } from "../components/Slot.js";
|
|
9
|
+
import { TranslationIcon } from "./TranslationIcon.js";
|
|
9
10
|
import { createContext, useContext, useId } from "react";
|
|
10
11
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
11
12
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
|
@@ -103,7 +104,7 @@ var FieldErrors = ({ className, ...props }) => {
|
|
|
103
104
|
})
|
|
104
105
|
});
|
|
105
106
|
};
|
|
106
|
-
var FieldLayout = ({ name, label, instructions, headerEnd, required, warning, errors = [], withControl = true, showInlineErrors, className, children, ...props }) => {
|
|
107
|
+
var FieldLayout = ({ name, label, instructions, headerEnd, required, warning, errors = [], withControl = true, showInlineErrors, translatable = false, className, children, ...props }) => {
|
|
107
108
|
const t = useTranslation();
|
|
108
109
|
const contextShowInlineErrors = useContext(InlineFieldErrorVisibilityContext);
|
|
109
110
|
const shouldShowInlineErrors = showInlineErrors ?? contextShowInlineErrors;
|
|
@@ -119,17 +120,28 @@ var FieldLayout = ({ name, label, instructions, headerEnd, required, warning, er
|
|
|
119
120
|
className: "min-w-0 space-y-0.5",
|
|
120
121
|
children: [label && /* @__PURE__ */ jsxs(FieldLabel, {
|
|
121
122
|
className: "flex items-center gap-1",
|
|
122
|
-
children: [
|
|
123
|
-
|
|
124
|
-
children:
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
123
|
+
children: [
|
|
124
|
+
label,
|
|
125
|
+
required && /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("span", {
|
|
126
|
+
className: "sr-only",
|
|
127
|
+
children: t("Required")
|
|
128
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
129
|
+
className: "text-rose-600",
|
|
130
|
+
"aria-hidden": "true",
|
|
131
|
+
children: /* @__PURE__ */ jsx(FontAwesomeIcon, {
|
|
132
|
+
icon: faAsterisk,
|
|
133
|
+
className: "size-[10px]"
|
|
134
|
+
})
|
|
135
|
+
})] }),
|
|
136
|
+
translatable ? /* @__PURE__ */ jsxs("span", {
|
|
137
|
+
className: "inline-flex",
|
|
138
|
+
title: t("Translatable"),
|
|
139
|
+
children: [/* @__PURE__ */ jsx(TranslationIcon, {}), /* @__PURE__ */ jsx("span", {
|
|
140
|
+
className: "sr-only",
|
|
141
|
+
children: t("Translatable")
|
|
142
|
+
})]
|
|
143
|
+
}) : null
|
|
144
|
+
]
|
|
133
145
|
}), instructions && /* @__PURE__ */ jsx(FieldInstructions, { children: instructions })]
|
|
134
146
|
}), headerEnd && /* @__PURE__ */ jsx("div", {
|
|
135
147
|
className: "shrink-0",
|
package/dist/forms/Field.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Field.js","names":[],"sources":["../../src/forms/Field.tsx"],"sourcesContent":["import {\n createContext, useContext, useId, type ComponentProps, type ReactNode,\n} from 'react';\nimport { Label, Markdown } from '@verbb/plugin-kit-react/components';\nimport { Slot } from '@verbb/plugin-kit-react/components/Slot';\nimport { cn } from '@verbb/plugin-kit-react/utils';\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome';\nimport { faAsterisk, faTriangleExclamation } from '@fortawesome/pro-solid-svg-icons';\nimport { useTranslation } from '@verbb/plugin-kit-react/hooks';\n\ntype FieldContextValue = {\n id: string;\n name: string;\n errors: string[];\n};\n\nconst FieldContext = createContext<FieldContextValue | null>(null);\nconst InlineFieldErrorVisibilityContext = createContext<boolean>(true);\n\nconst useFieldContext = () => {\n const context = useContext(FieldContext);\n if (!context) {\n throw new Error('Field components must be used within <FieldRoot>.');\n }\n return context;\n};\n\ntype FieldRootProps = ComponentProps<'div'> & {\n name: string;\n errors?: string[];\n};\n\nconst FieldRoot = ({\n name, errors = [], className, ...props\n}: FieldRootProps) => {\n const id = useId();\n return (\n <FieldContext.Provider value={{ id, name, errors }}>\n <div\n data-slot=\"field\"\n className={cn('space-y-1.5', className)}\n {...props}\n />\n </FieldContext.Provider>\n );\n};\n\nconst FieldHeader = ({ className, ...props }: ComponentProps<'div'>) => {\n return (\n <div data-slot=\"field-header\" className={cn(className)} {...props} />\n );\n};\n\nconst FieldLabel = ({ className, ...props }: ComponentProps<typeof Label>) => {\n const { id, errors } = useFieldContext();\n return (\n <Label\n data-slot=\"field-label\"\n htmlFor={`${id}-control`}\n data-error={errors.length > 0}\n className={cn('text-sm font-bold', className)}\n {...props}\n />\n );\n};\n\nconst FieldInstructions = ({ className, children, ...props }: ComponentProps<'p'>) => {\n const { id } = useFieldContext();\n const content = typeof children === 'string' ? children : null;\n\n const baseProps = {\n 'data-slot': 'field-instructions',\n id: `${id}-description`,\n className: cn('text-sm text-gray-500', className),\n };\n\n if (content !== null) {\n return (\n <Markdown\n content={content}\n inline\n as=\"p\"\n {...baseProps}\n />\n );\n }\n\n return (\n <p {...baseProps} {...props}>\n {children}\n </p>\n );\n};\n\ntype FieldControlProps = Omit<ComponentProps<typeof Slot>, 'className'> & {\n className?: string;\n};\n\nconst FieldControl = ({ className, ...props }: FieldControlProps) => {\n const { id, errors } = useFieldContext();\n const isInvalid = errors.length > 0;\n\n return (\n <Slot\n data-slot=\"field-control\"\n id={`${id}-control`}\n aria-invalid={isInvalid}\n aria-describedby={`${id}-description ${id}-errors`}\n aria-errormessage={isInvalid ? `${id}-errors` : undefined}\n className={cn(className)}\n {...props}\n />\n );\n};\n\nconst FieldErrors = ({ className, ...props }: ComponentProps<'ul'>) => {\n const { id, errors } = useFieldContext();\n if (!errors.length) {\n return null;\n }\n return (\n <ul\n data-slot=\"field-errors\"\n id={`${id}-errors`}\n className={cn('list-[square] text-error', className)}\n style={{ marginBlockStart: '5px', paddingInlineStart: '20px' }}\n {...props}\n >\n {errors.map((message, index) => {\n return (\n <li key={index}>\n <Markdown content={message} inline />\n </li>\n );\n })}\n </ul>\n );\n};\n\ntype FieldLayoutProps = ComponentProps<'div'> & {\n name: string;\n label?: string;\n instructions?: string;\n headerEnd?: ReactNode;\n required?: boolean;\n warning?: string;\n errors?: string[];\n withControl?: boolean;\n showInlineErrors?: boolean;\n};\n\nconst FieldLayout = ({\n name,\n label,\n instructions,\n headerEnd,\n required,\n warning,\n errors = [],\n withControl = true,\n showInlineErrors,\n className,\n children,\n ...props\n}: FieldLayoutProps) => {\n const t = useTranslation();\n const contextShowInlineErrors = useContext(InlineFieldErrorVisibilityContext);\n const shouldShowInlineErrors = showInlineErrors ?? contextShowInlineErrors;\n\n return (\n <FieldRoot name={name} errors={errors} className={className} {...props}>\n {(label || instructions || headerEnd) ? (\n <FieldHeader className={cn(\n headerEnd ? 'flex items-start justify-between gap-3' : 'space-y-0.5',\n )}>\n <div className=\"min-w-0 space-y-0.5\">\n {label && (\n <FieldLabel className=\"flex items-center gap-1\">\n {label}\n {required && (\n <>\n <span className=\"sr-only\">{t('Required')}</span>\n <span className=\"text-rose-600\" aria-hidden=\"true\">\n <FontAwesomeIcon icon={faAsterisk} className=\"size-[10px]\" />\n </span>\n </>\n )}\n </FieldLabel>\n )}\n {instructions && (\n <FieldInstructions>{instructions}</FieldInstructions>\n )}\n </div>\n\n {headerEnd && (\n <div className=\"shrink-0\">\n {headerEnd}\n </div>\n )}\n </FieldHeader>\n ) : null}\n\n {withControl ? (\n <FieldControl>{children}</FieldControl>\n ) : (\n children\n )}\n\n {shouldShowInlineErrors && <FieldErrors />}\n\n {warning && (\n <div className=\"flex min-w-0 items-start gap-1 text-sm text-warning\">\n <FontAwesomeIcon icon={faTriangleExclamation} className=\"mt-[0.3em] size-3 shrink-0\" />\n\n <Markdown\n className=\"min-w-0\"\n content={warning}\n inline\n as=\"p\"\n />\n </div>\n )}\n </FieldRoot>\n );\n};\n\nexport {\n FieldRoot,\n FieldHeader,\n FieldLabel,\n FieldInstructions,\n FieldControl,\n FieldErrors,\n FieldLayout,\n InlineFieldErrorVisibilityContext,\n useFieldContext,\n};\n"],"mappings":";;;;;;;;;;;;;AAgBA,IAAM,eAAe,cAAwC,KAAK;AAClE,IAAM,oCAAoC,cAAuB,KAAK;AAEtE,IAAM,wBAAwB;CAC1B,MAAM,UAAU,WAAW,aAAa;AACxC,KAAI,CAAC,QACD,OAAM,IAAI,MA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AAA,CAEvD;QAEL,aACG,oBAAC,OAAD;KAAK,WAAU;eACV;KACC,CAAA,CAEA;QACd;GAEH,cACG,oBAAC,cAAD,EAAe,UAAwB,CAAA,GAEvC;GAGH,0BAA0B,oBAAC,aAAD,EAAe,CAAA;GAEzC,WACG,qBAAC,OAAD;IAAK,WAAU;cAAf,CACI,oBAAC,iBAAD;KAAiB,MAAM;KAAuB,WAAU;KAA+B,CAAA,EAEvF,oBAAC,UAAD;KACI,WAAU;KACV,SAAS;KACT,QAAA;KACA,IAAG;KACL,CAAA,CACA;;GAEF"}
|
|
1
|
+
{"version":3,"file":"Field.js","names":[],"sources":["../../src/forms/Field.tsx"],"sourcesContent":["import {\n createContext, useContext, useId, type ComponentProps, type ReactNode,\n} from 'react';\nimport { Label, Markdown } from '@verbb/plugin-kit-react/components';\nimport { Slot } from '@verbb/plugin-kit-react/components/Slot';\nimport { cn } from '@verbb/plugin-kit-react/utils';\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome';\nimport { faAsterisk, faTriangleExclamation } from '@fortawesome/pro-solid-svg-icons';\nimport { useTranslation } from '@verbb/plugin-kit-react/hooks';\n\nimport { TranslationIcon } from './TranslationIcon';\n\ntype FieldContextValue = {\n id: string;\n name: string;\n errors: string[];\n};\n\nconst FieldContext = createContext<FieldContextValue | null>(null);\nconst InlineFieldErrorVisibilityContext = createContext<boolean>(true);\n\nconst useFieldContext = () => {\n const context = useContext(FieldContext);\n if (!context) {\n throw new Error('Field components must be used within <FieldRoot>.');\n }\n return context;\n};\n\ntype FieldRootProps = ComponentProps<'div'> & {\n name: string;\n errors?: string[];\n};\n\nconst FieldRoot = ({\n name, errors = [], className, ...props\n}: FieldRootProps) => {\n const id = useId();\n return (\n <FieldContext.Provider value={{ id, name, errors }}>\n <div\n data-slot=\"field\"\n className={cn('space-y-1.5', className)}\n {...props}\n />\n </FieldContext.Provider>\n );\n};\n\nconst FieldHeader = ({ className, ...props }: ComponentProps<'div'>) => {\n return (\n <div data-slot=\"field-header\" className={cn(className)} {...props} />\n );\n};\n\nconst FieldLabel = ({ className, ...props }: ComponentProps<typeof Label>) => {\n const { id, errors } = useFieldContext();\n return (\n <Label\n data-slot=\"field-label\"\n htmlFor={`${id}-control`}\n data-error={errors.length > 0}\n className={cn('text-sm font-bold', className)}\n {...props}\n />\n );\n};\n\nconst FieldInstructions = ({ className, children, ...props }: ComponentProps<'p'>) => {\n const { id } = useFieldContext();\n const content = typeof children === 'string' ? children : null;\n\n const baseProps = {\n 'data-slot': 'field-instructions',\n id: `${id}-description`,\n className: cn('text-sm text-gray-500', className),\n };\n\n if (content !== null) {\n return (\n <Markdown\n content={content}\n inline\n as=\"p\"\n {...baseProps}\n />\n );\n }\n\n return (\n <p {...baseProps} {...props}>\n {children}\n </p>\n );\n};\n\ntype FieldControlProps = Omit<ComponentProps<typeof Slot>, 'className'> & {\n className?: string;\n};\n\nconst FieldControl = ({ className, ...props }: FieldControlProps) => {\n const { id, errors } = useFieldContext();\n const isInvalid = errors.length > 0;\n\n return (\n <Slot\n data-slot=\"field-control\"\n id={`${id}-control`}\n aria-invalid={isInvalid}\n aria-describedby={`${id}-description ${id}-errors`}\n aria-errormessage={isInvalid ? `${id}-errors` : undefined}\n className={cn(className)}\n {...props}\n />\n );\n};\n\nconst FieldErrors = ({ className, ...props }: ComponentProps<'ul'>) => {\n const { id, errors } = useFieldContext();\n if (!errors.length) {\n return null;\n }\n return (\n <ul\n data-slot=\"field-errors\"\n id={`${id}-errors`}\n className={cn('list-[square] text-error', className)}\n style={{ marginBlockStart: '5px', paddingInlineStart: '20px' }}\n {...props}\n >\n {errors.map((message, index) => {\n return (\n <li key={index}>\n <Markdown content={message} inline />\n </li>\n );\n })}\n </ul>\n );\n};\n\ntype FieldLayoutProps = ComponentProps<'div'> & {\n name: string;\n label?: string;\n instructions?: string;\n headerEnd?: ReactNode;\n required?: boolean;\n warning?: string;\n errors?: string[];\n withControl?: boolean;\n showInlineErrors?: boolean;\n translatable?: boolean;\n};\n\nconst FieldLayout = ({\n name,\n label,\n instructions,\n headerEnd,\n required,\n warning,\n errors = [],\n withControl = true,\n showInlineErrors,\n translatable = false,\n className,\n children,\n ...props\n}: FieldLayoutProps) => {\n const t = useTranslation();\n const contextShowInlineErrors = useContext(InlineFieldErrorVisibilityContext);\n const shouldShowInlineErrors = showInlineErrors ?? contextShowInlineErrors;\n\n return (\n <FieldRoot name={name} errors={errors} className={className} {...props}>\n {(label || instructions || headerEnd) ? (\n <FieldHeader className={cn(\n headerEnd ? 'flex items-start justify-between gap-3' : 'space-y-0.5',\n )}>\n <div className=\"min-w-0 space-y-0.5\">\n {label && (\n <FieldLabel className=\"flex items-center gap-1\">\n {label}\n {required && (\n <>\n <span className=\"sr-only\">{t('Required')}</span>\n <span className=\"text-rose-600\" aria-hidden=\"true\">\n <FontAwesomeIcon icon={faAsterisk} className=\"size-[10px]\" />\n </span>\n </>\n )}\n {translatable ? (\n <span\n className=\"inline-flex\"\n title={t('Translatable')}\n >\n <TranslationIcon />\n <span className=\"sr-only\">{t('Translatable')}</span>\n </span>\n ) : null}\n </FieldLabel>\n )}\n {instructions && (\n <FieldInstructions>{instructions}</FieldInstructions>\n )}\n </div>\n\n {headerEnd && (\n <div className=\"shrink-0\">\n {headerEnd}\n </div>\n )}\n </FieldHeader>\n ) : null}\n\n {withControl ? (\n <FieldControl>{children}</FieldControl>\n ) : (\n children\n )}\n\n {shouldShowInlineErrors && <FieldErrors />}\n\n {warning && (\n <div className=\"flex min-w-0 items-start gap-1 text-sm text-warning\">\n <FontAwesomeIcon icon={faTriangleExclamation} className=\"mt-[0.3em] size-3 shrink-0\" />\n\n <Markdown\n className=\"min-w-0\"\n content={warning}\n inline\n as=\"p\"\n />\n </div>\n )}\n </FieldRoot>\n );\n};\n\nexport {\n FieldRoot,\n FieldHeader,\n FieldLabel,\n FieldInstructions,\n FieldControl,\n FieldErrors,\n FieldLayout,\n InlineFieldErrorVisibilityContext,\n useFieldContext,\n};\n"],"mappings":";;;;;;;;;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D;QAAM,WAAU;QAAgB,eAAY;kBACxC,oBAAC,iBAAD;SAAiB,MAAM;SAAY,WAAU;SAAgB,CAAA;QAC1D,CAAA,CACR,EAAA,CAAA;OAEN,eACG,qBAAC,QAAD;QACI,WAAU;QACV,OAAO,EAAE,eAAe;kBAF5B,CAII,oBAAC,iBAAD,EAAmB,CAAA,EACnB,oBAAC,QAAD;SAAM,WAAU;mBAAW,EAAE,eAAe;SAAQ,CAAA,CACjD;YACP;OACK;SAEhB,gBACG,oBAAC,mBAAD,EAAA,UAAoB,cAAiC,CAAA,CAEvD;QAEL,aACG,oBAAC,OAAD;KAAK,WAAU;eACV;KACC,CAAA,CAEA;QACd;GAEH,cACG,oBAAC,cAAD,EAAe,UAAwB,CAAA,GAEvC;GAGH,0BAA0B,oBAAC,aAAD,EAAe,CAAA;GAEzC,WACG,qBAAC,OAAD;IAAK,WAAU;cAAf,CACI,oBAAC,iBAAD;KAAiB,MAAM;KAAuB,WAAU;KAA+B,CAAA,EAEvF,oBAAC,UAAD;KACI,WAAU;KACV,SAAS;KACT,QAAA;KACA,IAAG;KACL,CAAA,CACA;;GAEF"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ComponentProps } from 'react';
|
|
2
|
+
type TranslationIconProps = ComponentProps<'svg'>;
|
|
3
|
+
declare const TranslationIcon: ({ className, ...props }: TranslationIconProps) => import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
export { TranslationIcon };
|
|
5
|
+
//# sourceMappingURL=TranslationIcon.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TranslationIcon.d.ts","sourceRoot":"","sources":["../../src/forms/TranslationIcon.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAI5C,KAAK,oBAAoB,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC;AAElD,QAAA,MAAM,eAAe,GAAI,yBAAyB,oBAAoB,4CAerE,CAAC;AAEF,OAAO,EAAE,eAAe,EAAE,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { cn } from "../utils/classes.js";
|
|
2
|
+
import "../utils/index.js";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
//#region src/forms/TranslationIcon.tsx
|
|
5
|
+
var TranslationIcon = ({ className, ...props }) => {
|
|
6
|
+
return /* @__PURE__ */ jsx("svg", {
|
|
7
|
+
"aria-hidden": "true",
|
|
8
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
9
|
+
viewBox: "0 0 640 512",
|
|
10
|
+
className: cn("size-4 fill-current text-gray-550", className),
|
|
11
|
+
...props,
|
|
12
|
+
children: /* @__PURE__ */ jsx("path", { d: "M64 64C28.7 64 0 92.7 0 128L0 384c0 35.3 28.7 64 64 64l208 0 32 0 16 0 256 0c35.3 0 64-28.7 64-64l0-256c0-35.3-28.7-64-64-64L320 64l-16 0-32 0L64 64zm512 48c8.8 0 16 7.2 16 16l0 256c0 8.8-7.2 16-16 16l-256 0 0-288 256 0zM178.3 175.9l64 144c4.5 10.1-.1 21.9-10.2 26.4s-21.9-.1-26.4-10.2L196.8 316l-73.6 0-8.9 20.1c-4.5 10.1-16.3 14.6-26.4 10.2s-14.6-16.3-10.2-26.4l64-144c3.2-7.2 10.4-11.9 18.3-11.9s15.1 4.7 18.3 11.9zM179 276l-19-42.8L141 276l38 0zM456 164c-11 0-20 9-20 20l0 4-52 0c-11 0-20 9-20 20s9 20 20 20l72 0 35.1 0c-7.3 16.7-17.4 31.9-29.8 45l-.5-.5-14.6-14.6c-7.8-7.8-20.5-7.8-28.3 0s-7.8 20.5 0 28.3L430 298.3c-5.9 3.6-12.1 6.9-18.5 9.8l-3.6 1.6c-10.1 4.5-14.6 16.3-10.2 26.4s16.3 14.6 26.4 10.2l3.6-1.6c12-5.3 23.4-11.8 34-19.4c4.3 3 8.6 5.8 13.1 8.5l18.9 11.3c9.5 5.7 21.8 2.6 27.4-6.9s2.6-21.8-6.9-27.4l-18.9-11.3c-.9-.5-1.8-1.1-2.7-1.6c17.2-18.8 30.7-40.9 39.6-65.4L534 228l2 0c11 0 20-9 20-20s-9-20-20-20l-16 0-44 0 0-4c0-11-9-20-20-20z" })
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
//#endregion
|
|
16
|
+
export { TranslationIcon };
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=TranslationIcon.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TranslationIcon.js","names":[],"sources":["../../src/forms/TranslationIcon.tsx"],"sourcesContent":["import type { ComponentProps } from 'react';\n\nimport { cn } from '@verbb/plugin-kit-react/utils';\n\ntype TranslationIconProps = ComponentProps<'svg'>;\n\nconst TranslationIcon = ({ className, ...props }: TranslationIconProps) => {\n return (\n <svg\n aria-hidden=\"true\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 640 512\"\n className={cn(\n 'size-4 fill-current text-gray-550',\n className,\n )}\n {...props}\n >\n <path d=\"M64 64C28.7 64 0 92.7 0 128L0 384c0 35.3 28.7 64 64 64l208 0 32 0 16 0 256 0c35.3 0 64-28.7 64-64l0-256c0-35.3-28.7-64-64-64L320 64l-16 0-32 0L64 64zm512 48c8.8 0 16 7.2 16 16l0 256c0 8.8-7.2 16-16 16l-256 0 0-288 256 0zM178.3 175.9l64 144c4.5 10.1-.1 21.9-10.2 26.4s-21.9-.1-26.4-10.2L196.8 316l-73.6 0-8.9 20.1c-4.5 10.1-16.3 14.6-26.4 10.2s-14.6-16.3-10.2-26.4l64-144c3.2-7.2 10.4-11.9 18.3-11.9s15.1 4.7 18.3 11.9zM179 276l-19-42.8L141 276l38 0zM456 164c-11 0-20 9-20 20l0 4-52 0c-11 0-20 9-20 20s9 20 20 20l72 0 35.1 0c-7.3 16.7-17.4 31.9-29.8 45l-.5-.5-14.6-14.6c-7.8-7.8-20.5-7.8-28.3 0s-7.8 20.5 0 28.3L430 298.3c-5.9 3.6-12.1 6.9-18.5 9.8l-3.6 1.6c-10.1 4.5-14.6 16.3-10.2 26.4s16.3 14.6 26.4 10.2l3.6-1.6c12-5.3 23.4-11.8 34-19.4c4.3 3 8.6 5.8 13.1 8.5l18.9 11.3c9.5 5.7 21.8 2.6 27.4-6.9s2.6-21.8-6.9-27.4l-18.9-11.3c-.9-.5-1.8-1.1-2.7-1.6c17.2-18.8 30.7-40.9 39.6-65.4L534 228l2 0c11 0 20-9 20-20s-9-20-20-20l-16 0-44 0 0-4c0-11-9-20-20-20z\" />\n </svg>\n );\n};\n\nexport { TranslationIcon };\n"],"mappings":";;;;AAMA,IAAM,mBAAmB,EAAE,WAAW,GAAG,YAAkC;AACvE,QACI,oBAAC,OAAD;EACI,eAAY;EACZ,OAAM;EACN,SAAQ;EACR,WAAW,GACP,qCACA,UACH;EACD,GAAI;YAEJ,oBAAC,QAAD,EAAM,GAAE,47BAA67B,CAAA;EACn8B,CAAA"}
|
|
@@ -10,6 +10,7 @@ type ListFieldProps = {
|
|
|
10
10
|
required?: boolean;
|
|
11
11
|
schema?: SchemaRenderable;
|
|
12
12
|
showGroupedErrors?: boolean;
|
|
13
|
+
className?: string;
|
|
13
14
|
};
|
|
14
15
|
};
|
|
15
16
|
export declare const ListField: ({ form, field }: ListFieldProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListField.d.ts","sourceRoot":"","sources":["../../../src/forms/fields/ListField.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,KAAK,EAAc,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE1E,KAAK,cAAc,GAAG;IAClB,IAAI,EAAE,mBAAmB,CAAC;IAC1B,KAAK,EAAE;QACH,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,MAAM,CAAC,EAAE,gBAAgB,CAAC;QAC1B,iBAAiB,CAAC,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"ListField.d.ts","sourceRoot":"","sources":["../../../src/forms/fields/ListField.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,KAAK,EAAc,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE1E,KAAK,cAAc,GAAG;IAClB,IAAI,EAAE,mBAAmB,CAAC;IAC1B,KAAK,EAAE;QACH,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,MAAM,CAAC,EAAE,gBAAgB,CAAC;QAC1B,iBAAiB,CAAC,EAAE,OAAO,CAAC;QAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;KACtB,CAAC;CACL,CAAC;AAEF,eAAO,MAAM,SAAS,GAAI,iBAAiB,cAAc,mDA6ExD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListField.js","names":[],"sources":["../../../src/forms/fields/ListField.tsx"],"sourcesContent":["import { FieldLayout } from '../Field';\nimport type { SchemaFormEngineApi } from '../engine/context';\nimport type { SchemaNode, SchemaRenderable } from '../engine/SchemaIndex';\n\ntype ListFieldProps = {\n form: SchemaFormEngineApi;\n field: {\n name: string;\n label?: string;\n instructions?: string;\n warning?: string;\n required?: boolean;\n schema?: SchemaRenderable;\n showGroupedErrors?: boolean;\n };\n};\n\nexport const ListField = ({ form, field }: ListFieldProps) => {\n const Renderer = form?.SchemaRenderer;\n const shouldShowGroupedErrors = field.showGroupedErrors !== false;\n const errors = shouldShowGroupedErrors\n ? (form?.getGroupedErrorsForPath?.(field.name)\n ?? form?.getErrorMapFields?.()[field.name]\n ?? [])\n : [];\n\n if (!Renderer) {\n return null;\n }\n\n const items = Array.isArray(form.getFieldValue(field.name)) ? form.getFieldValue(field.name) : [];\n const itemSchema = field.schema;\n\n return (\n <FieldLayout\n name={field.name}\n label={field.label}\n instructions={field.instructions}\n warning={field.warning}\n required={field.required}\n errors={errors}\n withControl={false}\n >\n {items.map((item, index) => {\n const modifyChildren = (children: SchemaRenderable | undefined): SchemaRenderable[] => {\n let normalizedChildren: SchemaRenderable[] = [];\n if (Array.isArray(children)) {\n normalizedChildren = children;\n } else if (children) {\n normalizedChildren = [children];\n }\n\n return normalizedChildren.map((child) => {\n if (!child || typeof child !== 'object' || Array.isArray(child)) {\n return child;\n }\n\n const childNode = child as SchemaNode;\n const shouldMapChildren = Boolean(childNode.children) && typeof childNode.children === 'object';\n const resolvedChildren = shouldMapChildren ? modifyChildren(childNode.children) : childNode.children;\n\n const childWithContext = {\n ...childNode,\n _data: {\n $item: item,\n $key: index,\n },\n children: resolvedChildren,\n };\n\n if (childNode.$field && typeof childNode.name === 'string') {\n return {\n ...childWithContext,\n name: `${field.name}.${index}.${childNode.name}`,\n };\n }\n\n return childWithContext;\n });\n };\n\n const modifiedChildren = modifyChildren(itemSchema);\n const key = item?._uid || item?.id || `${field.name}-${index}`;\n\n return (\n <Renderer\n key={key}\n schema={modifiedChildren}\n />\n );\n })}\n </FieldLayout>\n );\n};\n"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"ListField.js","names":[],"sources":["../../../src/forms/fields/ListField.tsx"],"sourcesContent":["import { FieldLayout } from '../Field';\nimport type { SchemaFormEngineApi } from '../engine/context';\nimport type { SchemaNode, SchemaRenderable } from '../engine/SchemaIndex';\n\ntype ListFieldProps = {\n form: SchemaFormEngineApi;\n field: {\n name: string;\n label?: string;\n instructions?: string;\n warning?: string;\n required?: boolean;\n schema?: SchemaRenderable;\n showGroupedErrors?: boolean;\n className?: string;\n };\n};\n\nexport const ListField = ({ form, field }: ListFieldProps) => {\n const Renderer = form?.SchemaRenderer;\n const shouldShowGroupedErrors = field.showGroupedErrors !== false;\n const errors = shouldShowGroupedErrors\n ? (form?.getGroupedErrorsForPath?.(field.name)\n ?? form?.getErrorMapFields?.()[field.name]\n ?? [])\n : [];\n\n if (!Renderer) {\n return null;\n }\n\n const items = Array.isArray(form.getFieldValue(field.name)) ? form.getFieldValue(field.name) : [];\n const itemSchema = field.schema;\n\n return (\n <FieldLayout\n name={field.name}\n label={field.label}\n instructions={field.instructions}\n warning={field.warning}\n required={field.required}\n errors={errors}\n withControl={false}\n className={field.className}\n >\n {items.map((item, index) => {\n const modifyChildren = (children: SchemaRenderable | undefined): SchemaRenderable[] => {\n let normalizedChildren: SchemaRenderable[] = [];\n if (Array.isArray(children)) {\n normalizedChildren = children;\n } else if (children) {\n normalizedChildren = [children];\n }\n\n return normalizedChildren.map((child) => {\n if (!child || typeof child !== 'object' || Array.isArray(child)) {\n return child;\n }\n\n const childNode = child as SchemaNode;\n const shouldMapChildren = Boolean(childNode.children) && typeof childNode.children === 'object';\n const resolvedChildren = shouldMapChildren ? modifyChildren(childNode.children) : childNode.children;\n\n const childWithContext = {\n ...childNode,\n _data: {\n $item: item,\n $key: index,\n },\n children: resolvedChildren,\n };\n\n if (childNode.$field && typeof childNode.name === 'string') {\n return {\n ...childWithContext,\n name: `${field.name}.${index}.${childNode.name}`,\n };\n }\n\n return childWithContext;\n });\n };\n\n const modifiedChildren = modifyChildren(itemSchema);\n const key = item?._uid || item?.id || `${field.name}-${index}`;\n\n return (\n <Renderer\n key={key}\n schema={modifiedChildren}\n />\n );\n })}\n </FieldLayout>\n );\n};\n"],"mappings":";;;AAkBA,IAAa,aAAa,EAAE,MAAM,YAA4B;CAC1D,MAAM,WAAW,MAAM;CAEvB,MAAM,SAD0B,MAAM,sBAAsB,QAErD,MAAM,0BAA0B,MAAM,KAAK,IACvC,MAA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Input;
|
|
18
18
|
linkSelectorStorageKeyPrefix?: string;
|
|
19
|
+
translatable?: boolean;
|
|
19
20
|
};
|
|
20
21
|
};
|
|
21
22
|
export declare const RichTextField: ({ form, field }: RichTextFieldProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RichTextField.d.ts","sourceRoot":"","sources":["../../../src/forms/fields/RichTextField.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAgB,MAAM,oCAAoC,CAAC;AAEpF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAI5E,KAAK,kBAAkB,GAAG;IACtB,IAAI,EAAE,mBAAmB,CAAC;IAC1B,KAAK,EAAE;QACH,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;QACnB,cAAc,CAAC,EAAE,cAAc,CAAC;QAChC,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,WAAW,CAAC,EAAE,gBAAgB,CAAC;QAC/B,4BAA4B,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"RichTextField.d.ts","sourceRoot":"","sources":["../../../src/forms/fields/RichTextField.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAgB,MAAM,oCAAoC,CAAC;AAEpF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAI5E,KAAK,kBAAkB,GAAG;IACtB,IAAI,EAAE,mBAAmB,CAAC;IAC1B,KAAK,EAAE;QACH,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;QACnB,cAAc,CAAC,EAAE,cAAc,CAAC;QAChC,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,WAAW,CAAC,EAAE,gBAAgB,CAAC;QAC/B,4BAA4B,CAAC,EAAE,MAAM,CAAC;QACtC,YAAY,CAAC,EAAE,OAAO,CAAC;KAC1B,CAAC;CACL,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,iBAAiB,kBAAkB,4CAkDhE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RichTextField.js","names":[],"sources":["../../../src/forms/fields/RichTextField.tsx"],"sourcesContent":["import { useMemo } from 'react';\nimport { LinkOptionsInput, TiptapEditor } from '@verbb/plugin-kit-react/components';\nimport { FieldLayout } from '../Field';\nimport type { SchemaFormEngineApi } from '../engine/context';\nimport type { VariableConfig } from '../contexts/VariableCategoriesContext';\nimport { useEngineField } from '../useEngineField';\nimport { useVariableCategoriesContext } from '../contexts/VariableCategoriesContext';\n\ntype RichTextFieldProps = {\n form: SchemaFormEngineApi;\n field: {\n name: string;\n label?: string;\n instructions?: string;\n warning?: string;\n placeholder?: string;\n buttons?: string[];\n variableConfig?: VariableConfig;\n required?: boolean;\n disabled?: boolean;\n rows?: number;\n linkOptions?: LinkOptionsInput;\n linkSelectorStorageKeyPrefix?: string;\n };\n};\n\nexport const RichTextField = ({ form, field }: RichTextFieldProps) => {\n const { value, setValue, errors } = useEngineField(form, field.name);\n const buttons = field.buttons ?? ['bold', 'italic'];\n const {\n getVariableCategories,\n variableCategoryLabels,\n variableCategoryOrder,\n variableTransformerRegistry,\n renderVariableConfigureSection,\n resolveVariableTagLabel,\n } = useVariableCategoriesContext();\n const { variableConfig } = field;\n\n const variableCategories = useMemo(() => {\n if (!variableConfig || !getVariableCategories) {\n return undefined;\n }\n return getVariableCategories(variableConfig, { form });\n }, [variableConfig, form, getVariableCategories]);\n\n return (\n <FieldLayout\n name={field.name}\n label={field.label}\n instructions={field.instructions}\n warning={field.warning}\n required={field.required}\n errors={errors}\n withControl={false}\n >\n <TiptapEditor\n value={value ?? ''}\n onChange={setValue}\n placeholder={field.placeholder}\n rows={field.rows}\n buttons={buttons}\n {...(variableCategories && { variableCategories })}\n {...(variableCategoryLabels && { variableCategoryLabels })}\n {...(variableCategoryOrder && { variableCategoryOrder })}\n {...(variableTransformerRegistry && { variableTransformerRegistry })}\n {...(renderVariableConfigureSection && { renderVariableConfigureSection })}\n {...(resolveVariableTagLabel && { resolveVariableTagLabel })}\n {...(field.linkOptions && { linkOptions: field.linkOptions })}\n {...(field.linkSelectorStorageKeyPrefix && { linkSelectorStorageKeyPrefix: field.linkSelectorStorageKeyPrefix })}\n disabled={field.disabled}\n isInvalid={errors.length > 0}\n />\n </FieldLayout>\n );\n};\n"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"RichTextField.js","names":[],"sources":["../../../src/forms/fields/RichTextField.tsx"],"sourcesContent":["import { useMemo } from 'react';\nimport { LinkOptionsInput, TiptapEditor } from '@verbb/plugin-kit-react/components';\nimport { FieldLayout } from '../Field';\nimport type { SchemaFormEngineApi } from '../engine/context';\nimport type { VariableConfig } from '../contexts/VariableCategoriesContext';\nimport { useEngineField } from '../useEngineField';\nimport { useVariableCategoriesContext } from '../contexts/VariableCategoriesContext';\n\ntype RichTextFieldProps = {\n form: SchemaFormEngineApi;\n field: {\n name: string;\n label?: string;\n instructions?: string;\n warning?: string;\n placeholder?: string;\n buttons?: string[];\n variableConfig?: VariableConfig;\n required?: boolean;\n disabled?: boolean;\n rows?: number;\n linkOptions?: LinkOptionsInput;\n linkSelectorStorageKeyPrefix?: string;\n translatable?: boolean;\n };\n};\n\nexport const RichTextField = ({ form, field }: RichTextFieldProps) => {\n const { value, setValue, errors } = useEngineField(form, field.name);\n const buttons = field.buttons ?? ['bold', 'italic'];\n const {\n getVariableCategories,\n variableCategoryLabels,\n variableCategoryOrder,\n variableTransformerRegistry,\n renderVariableConfigureSection,\n resolveVariableTagLabel,\n } = useVariableCategoriesContext();\n const { variableConfig } = field;\n\n const variableCategories = useMemo(() => {\n if (!variableConfig || !getVariableCategories) {\n return undefined;\n }\n return getVariableCategories(variableConfig, { form });\n }, [variableConfig, form, getVariableCategories]);\n\n return (\n <FieldLayout\n name={field.name}\n label={field.label}\n instructions={field.instructions}\n warning={field.warning}\n required={field.required}\n translatable={field.translatable}\n errors={errors}\n withControl={false}\n >\n <TiptapEditor\n value={value ?? ''}\n onChange={setValue}\n placeholder={field.placeholder}\n rows={field.rows}\n buttons={buttons}\n {...(variableCategories && { variableCategories })}\n {...(variableCategoryLabels && { variableCategoryLabels })}\n {...(variableCategoryOrder && { variableCategoryOrder })}\n {...(variableTransformerRegistry && { variableTransformerRegistry })}\n {...(renderVariableConfigureSection && { renderVariableConfigureSection })}\n {...(resolveVariableTagLabel && { resolveVariableTagLabel })}\n {...(field.linkOptions && { linkOptions: field.linkOptions })}\n {...(field.linkSelectorStorageKeyPrefix && { linkSelectorStorageKeyPrefix: field.linkSelectorStorageKeyPrefix })}\n disabled={field.disabled}\n isInvalid={errors.length > 0}\n />\n </FieldLayout>\n );\n};\n"],"mappings":";;;;;;;;AA2BA,IAAa,iBAAiB,EAAE,MAAM,YAAgC;CAClE,MAAM,EAAE,OAAO,UAAU,WAAW,eAAe,MAAM,MAAM,KAAK;CACpE,MAAM,UAAU,MAAM,WAAW,CAAC,QAAQ,SAAS;CACnD,MAAM,EACF,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AiB,EAAE,CAAC;QAC9B,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;KACtB,CAAC;CACL,CAAC;AAIF,eAAO,MAAM,WAAW,GAAI,iBAAiB,gBAAgB,4CA2E5D,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectField.js","names":[],"sources":["../../../src/forms/fields/SelectField.tsx"],"sourcesContent":["import type React from 'react';\nimport { SelectInput } from '@verbb/plugin-kit-react/components';\nimport { evaluateCondition } from '@verbb/plugin-kit-react/utils/schema';\nimport { useEffect, useMemo, useSyncExternalStore } from 'react';\nimport { FieldLayout } from '../Field';\nimport type { SchemaFormEngineApi } from '../engine/context';\nimport type { SchemaNode } from '../engine/SchemaIndex';\nimport { useEngineField } from '../useEngineField';\n\ntype SelectFieldOption = {\n value: unknown;\n label: string;\n disabled?: boolean;\n if?: string;\n [key: string]: unknown;\n};\n\ntype SelectFieldProps = {\n form: SchemaFormEngineApi;\n field: SchemaNode & {\n name: string;\n label?: string;\n instructions?: string;\n warning?: string;\n placeholder?: string;\n options?: SelectFieldOption[];\n required?: boolean;\n disabled?: boolean;\n };\n};\n\ntype SelectInputProps = React.ComponentProps<typeof SelectInput>;\n\nexport const SelectField = ({ form, field }: SelectFieldProps) => {\n const {\n value, setValue, setTouched, errors, isInvalid,\n } = useEngineField(form, field.name);\n const values = useSyncExternalStore(\n form.store.subscribe.bind(form.store),\n () => { return form.store.state.values; },\n () => { return form.store.state.values; },\n );\n\n const conditionData = useMemo(() => {\n const scopePath = typeof field._scopePath === 'string' ? field._scopePath : '';\n const scopedValues = scopePath ? form?.getFieldValue?.(scopePath) : null;\n const scopedObject = scopedValues && typeof scopedValues === 'object' ? scopedValues : {};\n const fieldData = (field._data && typeof field._data === 'object') ? field._data : {};\n\n return {\n ...(values || {}),\n ...scopedObject,\n ...fieldData,\n };\n }, [field, form, values]);\n\n const filteredOptions = useMemo(() => {\n const options = Array.isArray(field.options) ? field.options : [];\n\n return options.filter((option) => {\n if (!option?.if) {\n return true;\n }\n\n return evaluateCondition(option.if, conditionData);\n });\n }, [conditionData, field.options]);\n\n useEffect(() => {\n if (value === undefined || value === null || value === '') {\n return;\n }\n\n const hasCurrentValue = filteredOptions.some((option) => {\n return String(option?.value) === String(value);\n });\n\n if (hasCurrentValue) {\n return;\n }\n\n const fallback = filteredOptions.find((option) => {\n return option?.value !== undefined && option?.disabled !== true;\n });\n\n setValue(fallback ? fallback.value : '');\n }, [filteredOptions, setValue, value]);\n\n return (\n <FieldLayout\n name={field.name}\n label={field.label}\n instructions={field.instructions}\n warning={field.warning}\n required={field.required}\n errors={errors}\n >\n <SelectInput\n options={filteredOptions}\n placeholder={field.placeholder}\n value={value ?? ''}\n onChange={(nextValue) => { return setValue(nextValue); }}\n isInvalid={isInvalid}\n onBlur={setTouched as SelectInputProps['onBlur']}\n />\n </FieldLayout>\n );\n};\n"],"mappings":";;;;;;;;AAiCA,IAAa,eAAe,EAAE,MAAM,YAA8B;CAC9D,MAAM,EACF,OAAO,UAAU,YAAY,QAAQ,cACrC,eAAe,MAAM,MAAM,KAAK;CACpC,MAAM,SAAS,qBACX,KAAK,MAAM,UAAU,KAAK,KAAK,MAAM,QAC/B;AAAE,SAAO,KAAK,MAAM,MAAM;UAC1B;AAAE,SAAO,KAAK,MAAM,MAAM;GACnC;CAED,MAAM,gBAAgB,cAAc;EAChC,MAAM,YAAY,OAAO,MAAM,eAAe,WAAW,MAAM,aAAa;EAC5E,MAAM,eAAe,YAAY,MAAM,gBAAgB,UAAU,GAAG;EACpE,MAAM,eAAe,gBAAgB,OAAO,iBAAiB,WAAW,eAAe,EAAE;EACzF,MAAM,YAAa,MAAM,SAAS,OAAO,MAAM,UAAU,WAAY,MAAM,QAAQ,EAAE;AAErF,SAAO;GACH,GAAI,UAAU,EAAE;GAChB,GAAG;GACH,GAAG;GACN;IACF;EAAC;EAAO;EAAM;EAAO,CAAC;CAEzB,MAAM,kBAAkB,cAAc;AAGlC,UAFgB,MAAM,QAAQ,MAAM,QAAQ,GAAG,MAAM,UAAU,EAAE,EAElD,QAAQ,WAAW;AAC9B,OAAI,CAAC,QAAQ,GACT,QAAO;AAGX,UAAO,kBAAkB,OAAO,IAAI,cAAc;IACpD;IACH,CAAC,eAAe,MAAM,QAAQ,CAAC;AAElC,iBAAgB;AACZ,MAAI,UAAU,KAAA,KAAa,UAAU,QAAQ,UAAU,GACnD;AAOJ,MAJwB,gBAAgB,MAAM,WAAW;AACrD,UAAO,OAAO,QAAQ,MAAM,KAAK,OAAO,MAAM;IAG9C,CACA;EAGJ,MAAM,WAAW,gBAAgB,MAAM,WAAW;AAC9C,UAAO,QAAQ,UAAU,KAAA,KAAa,QAAQ,aAAa;IAC7D;AAEF,WAAS,WAAW,SAAS,QAAQ,GAAG;IACzC;EAAC;EAAiB;EAAU;EAAM,CAAC;AAEtC,QACI,oBAAC,aAAD;EACI,MAAM,MAAM;EACZ,OAAO,MAAM;EACb,cAAc,MAAM;EACpB,SAAS,MAAM;EACf,UAAU,MAAM;EACR;YAER,oBAAC,aAAD;GACI,SAAS;GACT,aAAa,MAAM;GACnB,OAAO,SAAS;GAChB,WAAW,cAAc;AAAE,WAAO,SAAS,UAAU;;GAC1C;GACX,QAAQ;
|
|
1
|
+
{"version":3,"file":"SelectField.js","names":[],"sources":["../../../src/forms/fields/SelectField.tsx"],"sourcesContent":["import type React from 'react';\nimport { SelectInput } from '@verbb/plugin-kit-react/components';\nimport { evaluateCondition } from '@verbb/plugin-kit-react/utils/schema';\nimport { useEffect, useMemo, useSyncExternalStore } from 'react';\nimport { FieldLayout } from '../Field';\nimport type { SchemaFormEngineApi } from '../engine/context';\nimport type { SchemaNode } from '../engine/SchemaIndex';\nimport { useEngineField } from '../useEngineField';\n\ntype SelectFieldOption = {\n value: unknown;\n label: string;\n disabled?: boolean;\n if?: string;\n [key: string]: unknown;\n};\n\ntype SelectFieldProps = {\n form: SchemaFormEngineApi;\n field: SchemaNode & {\n name: string;\n label?: string;\n instructions?: string;\n warning?: string;\n placeholder?: string;\n options?: SelectFieldOption[];\n required?: boolean;\n disabled?: boolean;\n };\n};\n\ntype SelectInputProps = React.ComponentProps<typeof SelectInput>;\n\nexport const SelectField = ({ form, field }: SelectFieldProps) => {\n const {\n value, setValue, setTouched, errors, isInvalid,\n } = useEngineField(form, field.name);\n const values = useSyncExternalStore(\n form.store.subscribe.bind(form.store),\n () => { return form.store.state.values; },\n () => { return form.store.state.values; },\n );\n\n const conditionData = useMemo(() => {\n const scopePath = typeof field._scopePath === 'string' ? field._scopePath : '';\n const scopedValues = scopePath ? form?.getFieldValue?.(scopePath) : null;\n const scopedObject = scopedValues && typeof scopedValues === 'object' ? scopedValues : {};\n const fieldData = (field._data && typeof field._data === 'object') ? field._data : {};\n\n return {\n ...(values || {}),\n ...scopedObject,\n ...fieldData,\n };\n }, [field, form, values]);\n\n const filteredOptions = useMemo(() => {\n const options = Array.isArray(field.options) ? field.options : [];\n\n return options.filter((option) => {\n if (!option?.if) {\n return true;\n }\n\n return evaluateCondition(option.if, conditionData);\n });\n }, [conditionData, field.options]);\n\n useEffect(() => {\n if (value === undefined || value === null || value === '') {\n return;\n }\n\n const hasCurrentValue = filteredOptions.some((option) => {\n return String(option?.value) === String(value);\n });\n\n if (hasCurrentValue) {\n return;\n }\n\n const fallback = filteredOptions.find((option) => {\n return option?.value !== undefined && option?.disabled !== true;\n });\n\n setValue(fallback ? fallback.value : '');\n }, [filteredOptions, setValue, value]);\n\n return (\n <FieldLayout\n name={field.name}\n label={field.label}\n instructions={field.instructions}\n warning={field.warning}\n required={field.required}\n errors={errors}\n >\n <SelectInput\n options={filteredOptions}\n placeholder={field.placeholder}\n value={value ?? ''}\n onChange={(nextValue) => { return setValue(nextValue); }}\n isInvalid={isInvalid}\n onBlur={setTouched as SelectInputProps['onBlur']}\n disabled={field.disabled}\n />\n </FieldLayout>\n );\n};\n"],"mappings":";;;;;;;;AAiCA,IAAa,eAAe,EAAE,M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;EACpB,SAAS,MAAM;EACf,UAAU,MAAM;EACR;YAER,oBAAC,aAAD;GACI,SAAS;GACT,aAAa,MAAM;GACnB,OAAO,SAAS;GAChB,WAAW,cAAc;AAAE,WAAO,SAAS,UAAU;;GAC1C;GACX,QAAQ;GACR,UAAU,MAAM;GAClB,CAAA;EACQ,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextField.d.ts","sourceRoot":"","sources":["../../../src/forms/fields/TextField.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAG7D,KAAK,cAAc,GAAG;IAClB,IAAI,EAAE,mBAAmB,CAAC;IAC1B,KAAK,EAAE;QACH,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"TextField.d.ts","sourceRoot":"","sources":["../../../src/forms/fields/TextField.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAG7D,KAAK,cAAc,GAAG;IAClB,IAAI,EAAE,mBAAmB,CAAC;IAC1B,KAAK,EAAE;QACH,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,YAAY,CAAC,EAAE,OAAO,CAAC;KAC1B,CAAC;CACL,CAAC;AAEF,eAAO,MAAM,SAAS,GAAI,iBAAiB,cAAc,4CAyBxD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextField.js","names":[],"sources":["../../../src/forms/fields/TextField.tsx"],"sourcesContent":["import { Input } from '@verbb/plugin-kit-react/components';\nimport { FieldLayout } from '../Field';\nimport type { SchemaFormEngineApi } from '../engine/context';\nimport { useEngineField } from '../useEngineField';\n\ntype TextFieldProps = {\n form: SchemaFormEngineApi;\n field: {\n name: string;\n label?: string;\n instructions?: string;\n warning?: string;\n placeholder?: string;\n required?: boolean;\n disabled?: boolean;\n };\n};\n\nexport const TextField = ({ form, field }: TextFieldProps) => {\n const {\n value, setValue, setTouched, errors, isInvalid,\n } = useEngineField(form, field.name);\n\n return (\n <FieldLayout\n name={field.name}\n label={field.label}\n instructions={field.instructions}\n warning={field.warning}\n required={field.required}\n errors={errors}\n >\n <Input\n value={String(value ?? '')}\n onChange={(event) => { return setValue(event.target.value); }}\n onBlur={setTouched}\n placeholder={field.placeholder}\n disabled={field.disabled}\n aria-invalid={isInvalid}\n />\n </FieldLayout>\n );\n};\n"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"TextField.js","names":[],"sources":["../../../src/forms/fields/TextField.tsx"],"sourcesContent":["import { Input } from '@verbb/plugin-kit-react/components';\nimport { FieldLayout } from '../Field';\nimport type { SchemaFormEngineApi } from '../engine/context';\nimport { useEngineField } from '../useEngineField';\n\ntype TextFieldProps = {\n form: SchemaFormEngineApi;\n field: {\n name: string;\n label?: string;\n instructions?: string;\n warning?: string;\n placeholder?: string;\n required?: boolean;\n disabled?: boolean;\n translatable?: boolean;\n };\n};\n\nexport const TextField = ({ form, field }: TextFieldProps) => {\n const {\n value, setValue, setTouched, errors, isInvalid,\n } = useEngineField(form, field.name);\n\n return (\n <FieldLayout\n name={field.name}\n label={field.label}\n instructions={field.instructions}\n warning={field.warning}\n required={field.required}\n translatable={field.translatable}\n errors={errors}\n >\n <Input\n value={String(value ?? '')}\n onChange={(event) => { return setValue(event.target.value); }}\n onBlur={setTouched}\n placeholder={field.placeholder}\n disabled={field.disabled}\n aria-invalid={isInvalid}\n />\n </FieldLayout>\n );\n};\n"],"mappings":";;;;;;AAmBA,IAAa,aAAa,EAAE,MAAM,YAA4B;CAC1D,MAAM,EACF,OAAO,UAAU,YAAY,QAAQ,cACrC,eAAe,MAAM,MAAM,KAAK;AAEpC,QACI,oBAAC,aAAD;EACI,MAAM,MAAM;EACZ,OAAO,MAAM;EACb,cAAc,MAAM;EACpB,SAAS,MAAM;EACf,UAAU,MAAM;EAChB,cAAc,MAAM;EACZ;YAER,oBAAC,OAAD;GACI,OAAO,OAAO,SAAS,GAAG;GAC1B,WAAW,UAAU;AAAE,WAAO,SAAS,MAAM,OAAO,MAAM;;GAC1D,QAAQ;GACR,aAAa,MAAM;GACnB,UAAU,MAAM;GAChB,gBAAc;GAChB,CAAA;EACQ,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextareaField.d.ts","sourceRoot":"","sources":["../../../src/forms/fields/TextareaField.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAG7D,KAAK,kBAAkB,GAAG;IACtB,IAAI,EAAE,mBAAmB,CAAC;IAC1B,KAAK,EAAE;QACH,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"TextareaField.d.ts","sourceRoot":"","sources":["../../../src/forms/fields/TextareaField.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAG7D,KAAK,kBAAkB,GAAG;IACtB,IAAI,EAAE,mBAAmB,CAAC;IAC1B,KAAK,EAAE;QACH,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,YAAY,CAAC,EAAE,OAAO,CAAC;KAC1B,CAAC;CACL,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,iBAAiB,kBAAkB,4CA0BhE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextareaField.js","names":[],"sources":["../../../src/forms/fields/TextareaField.tsx"],"sourcesContent":["import { Textarea } from '@verbb/plugin-kit-react/components';\nimport { FieldLayout } from '../Field';\nimport type { SchemaFormEngineApi } from '../engine/context';\nimport { useEngineField } from '../useEngineField';\n\ntype TextareaFieldProps = {\n form: SchemaFormEngineApi;\n field: {\n name: string;\n label?: string;\n instructions?: string;\n warning?: string;\n placeholder?: string;\n rows?: number;\n required?: boolean;\n disabled?: boolean;\n };\n};\n\nexport const TextareaField = ({ form, field }: TextareaFieldProps) => {\n const {\n value, setValue, setTouched, errors, isInvalid,\n } = useEngineField(form, field.name);\n\n return (\n <FieldLayout\n name={field.name}\n label={field.label}\n instructions={field.instructions}\n warning={field.warning}\n required={field.required}\n errors={errors}\n >\n <Textarea\n value={String(value ?? '')}\n onChange={(event) => { return setValue(event.target.value); }}\n onBlur={setTouched}\n placeholder={field.placeholder}\n disabled={field.disabled}\n rows={field.rows}\n aria-invalid={isInvalid}\n />\n </FieldLayout>\n );\n};\n"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"TextareaField.js","names":[],"sources":["../../../src/forms/fields/TextareaField.tsx"],"sourcesContent":["import { Textarea } from '@verbb/plugin-kit-react/components';\nimport { FieldLayout } from '../Field';\nimport type { SchemaFormEngineApi } from '../engine/context';\nimport { useEngineField } from '../useEngineField';\n\ntype TextareaFieldProps = {\n form: SchemaFormEngineApi;\n field: {\n name: string;\n label?: string;\n instructions?: string;\n warning?: string;\n placeholder?: string;\n rows?: number;\n required?: boolean;\n disabled?: boolean;\n translatable?: boolean;\n };\n};\n\nexport const TextareaField = ({ form, field }: TextareaFieldProps) => {\n const {\n value, setValue, setTouched, errors, isInvalid,\n } = useEngineField(form, field.name);\n\n return (\n <FieldLayout\n name={field.name}\n label={field.label}\n instructions={field.instructions}\n warning={field.warning}\n required={field.required}\n translatable={field.translatable}\n errors={errors}\n >\n <Textarea\n value={String(value ?? '')}\n onChange={(event) => { return setValue(event.target.value); }}\n onBlur={setTouched}\n placeholder={field.placeholder}\n disabled={field.disabled}\n rows={field.rows}\n aria-invalid={isInvalid}\n />\n </FieldLayout>\n );\n};\n"],"mappings":";;;;;;AAoBA,IAAa,iBAAiB,EAAE,MAAM,YAAgC;CAClE,MAAM,EACF,OAAO,UAAU,YAAY,QAAQ,cACrC,eAAe,MAAM,MAAM,KAAK;AAEpC,QACI,oBAAC,aAAD;EACI,MAAM,MAAM;EACZ,OAAO,MAAM;EACb,cAAc,MAAM;EACpB,SAAS,MAAM;EACf,UAAU,MAAM;EAChB,cAAc,MAAM;EACZ;YAER,oBAAC,UAAD;GACI,OAAO,OAAO,SAAS,GAAG;GAC1B,WAAW,UAAU;AAAE,WAAO,SAAS,MAAM,OAAO,MAAM;;GAC1D,QAAQ;GACR,aAAa,MAAM;GACnB,UAAU,MAAM;GAChB,MAAM,MAAM;GACZ,gBAAc;GAChB,CAAA;EACQ,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@verbb/plugin-kit-react",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.9",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -154,7 +154,7 @@
|
|
|
154
154
|
"@tiptap/react": "^3.22.4",
|
|
155
155
|
"@types/prismjs": "^1.26.6",
|
|
156
156
|
"@uiw/react-codemirror": "^4.25.10",
|
|
157
|
-
"@verbb/plugin-kit": "1.0.
|
|
157
|
+
"@verbb/plugin-kit": "1.0.9",
|
|
158
158
|
"class-variance-authority": "^0.7.1",
|
|
159
159
|
"clsx": "^2.1.1",
|
|
160
160
|
"cmdk": "^1.1.1",
|