@scaleflex/ui-tw 0.0.14 → 0.0.16

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.
@@ -1,5 +1,5 @@
1
1
  import { FormSwitchFieldProps } from '@scaleflex/ui-tw/form/form.types';
2
2
  import React from 'react';
3
3
  import { FieldValues, Path } from 'react-hook-form';
4
- declare function FormSwitchField<TFieldValues extends FieldValues, TName extends Path<TFieldValues>>({ control, name, label, description, disabled, tooltip, size, layout, }: FormSwitchFieldProps<TFieldValues, TName>): React.JSX.Element;
4
+ declare function FormSwitchField<TFieldValues extends FieldValues, TName extends Path<TFieldValues>>({ control, name, label, description, disabled, tooltip, size, layout, switchProps, }: FormSwitchFieldProps<TFieldValues, TName>): React.JSX.Element;
5
5
  export { FormSwitchField };
@@ -1,3 +1,4 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
1
2
  import { FormControl, FormDescription, FormField, FormItem, FormMessage } from '@scaleflex/ui-tw/form';
2
3
  import { SwitchLayout, formSwitchFieldSizeOptions } from '@scaleflex/ui-tw/form/form.constants';
3
4
  import { Label } from '@scaleflex/ui-tw/label';
@@ -24,7 +25,8 @@ function FormSwitchField(_ref) {
24
25
  _ref$size = _ref.size,
25
26
  size = _ref$size === void 0 ? FormSize.Md : _ref$size,
26
27
  _ref$layout = _ref.layout,
27
- layout = _ref$layout === void 0 ? SwitchLayout.Inline : _ref$layout;
28
+ layout = _ref$layout === void 0 ? SwitchLayout.Inline : _ref$layout,
29
+ switchProps = _ref.switchProps;
28
30
  var isInlineLayout = layout === SwitchLayout.Inline;
29
31
  return /*#__PURE__*/React.createElement(FormField, {
30
32
  control: control,
@@ -35,13 +37,13 @@ function FormSwitchField(_ref) {
35
37
  className: cn('flex items-center', isInlineLayout ? formSwitchFieldVariants({
36
38
  size: size
37
39
  }) : 'w-full justify-between gap-2')
38
- }, isInlineLayout ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FormControl, null, /*#__PURE__*/React.createElement(Switch, {
40
+ }, isInlineLayout ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FormControl, null, /*#__PURE__*/React.createElement(Switch, _extends({
39
41
  id: field.name,
40
42
  checked: field.value,
41
43
  onCheckedChange: field.onChange,
42
44
  disabled: disabled,
43
45
  size: size
44
- })), /*#__PURE__*/React.createElement(Label, {
46
+ }, switchProps))), /*#__PURE__*/React.createElement(Label, {
45
47
  htmlFor: field.name,
46
48
  tooltip: tooltip,
47
49
  size: size
@@ -1,5 +1,6 @@
1
1
  import { FormMessageSize, SwitchLayout } from '@scaleflex/ui-tw/form/form.constants';
2
2
  import { InputProps } from '@scaleflex/ui-tw/input';
3
+ import { SwitchProps } from '@scaleflex/ui-tw/switch/switch.types';
3
4
  import { TextareaProps } from '@scaleflex/ui-tw/textarea';
4
5
  import { FormSizeType } from '@scaleflex/ui-tw/types/form-size';
5
6
  import type { Values } from '@scaleflex/ui-tw/types/values';
@@ -36,6 +37,7 @@ export interface FormSwitchFieldProps<TFieldValues extends FieldValues, TName ex
36
37
  disabled?: boolean;
37
38
  layout?: SwitchLayoutType;
38
39
  tooltip?: ReactElement | string;
40
+ switchProps?: SwitchProps;
39
41
  }
40
42
  export type FormInputFieldProps<TFieldValues extends FieldValues, TName extends Path<TFieldValues>> = Omit<FormFieldGroupProps<TFieldValues, TName>, 'children'> & {
41
43
  inputProps?: InputProps;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scaleflex/ui-tw",
3
- "version": "0.0.14",
3
+ "version": "0.0.16",
4
4
  "author": "scaleflex",
5
5
  "repository": "github:scaleflex/ui",
6
6
  "homepage": "https://github.com/scaleflex/ui/blob/master/README.md",
@@ -17,7 +17,7 @@
17
17
  "@radix-ui/react-slot": "^1.1.2",
18
18
  "@radix-ui/react-switch": "^1.0.1",
19
19
  "@radix-ui/react-tooltip": "^1.2.6",
20
- "@scaleflex/icons-tw": "^0.0.14",
20
+ "@scaleflex/icons-tw": "^0.0.16",
21
21
  "@types/lodash.merge": "^4.6.9",
22
22
  "class-variance-authority": "^0.7.1",
23
23
  "lodash.merge": "^4.6.2",
@@ -61,6 +61,7 @@ function WithTooltip(_ref5) {
61
61
  var variant = _ref5.variant,
62
62
  content = _ref5.content,
63
63
  children = _ref5.children;
64
+ if (!content) return children;
64
65
  return /*#__PURE__*/React.createElement(Tooltip, null, /*#__PURE__*/React.createElement(TooltipTrigger, {
65
66
  asChild: true
66
67
  }, children), /*#__PURE__*/React.createElement(TooltipContent, {
@@ -3,7 +3,7 @@ import { TooltipVariant } from '@scaleflex/ui-tw/tooltip/tooltip.constants';
3
3
  import { ComponentProps, ReactElement } from 'react';
4
4
  export type TooltipVariantType = (typeof TooltipVariant)[keyof typeof TooltipVariant];
5
5
  export interface WithTooltipProps {
6
- content: ReactElement;
6
+ content?: ReactElement | undefined | string;
7
7
  children: ReactElement;
8
8
  variant?: TooltipVariantType;
9
9
  }