@uxf/ui 1.0.0-beta.55 → 1.0.0-beta.57

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.
Files changed (51) hide show
  1. package/_private-utils/get-provider-config.d.ts +2 -0
  2. package/_private-utils/get-provider-config.js +7 -0
  3. package/button/button.d.ts +2 -3
  4. package/button/button.js +6 -7
  5. package/button/index.d.ts +0 -1
  6. package/button/index.js +0 -6
  7. package/checkbox/checkbox.d.ts +5 -8
  8. package/checkbox/checkbox.js +9 -11
  9. package/checkbox/checkbox.stories.d.ts +2 -3
  10. package/checkbox/checkbox.stories.js +21 -4
  11. package/checkbox/index.d.ts +1 -1
  12. package/checkbox/index.js +1 -4
  13. package/content/content-schema.d.ts +3 -0
  14. package/content/content-schema.js +2 -0
  15. package/content/types.d.ts +27 -0
  16. package/content/types.js +2 -0
  17. package/context/context.d.ts +12 -0
  18. package/context/context.js +5 -0
  19. package/context/index.d.ts +3 -0
  20. package/context/index.js +19 -0
  21. package/context/provider.d.ts +8 -0
  22. package/context/provider.js +10 -0
  23. package/context/use-component-context.d.ts +3 -0
  24. package/context/use-component-context.js +13 -0
  25. package/css/checkbox.css +78 -12
  26. package/css/radio-group.css +107 -1
  27. package/css/radio.css +79 -9
  28. package/css/toggle.css +60 -0
  29. package/dropdown/dropdown.d.ts +1 -1
  30. package/icon/icon.d.ts +1 -2
  31. package/icon/icon.js +4 -2
  32. package/icon/types.d.ts +2 -0
  33. package/icon/types.js +2 -0
  34. package/package.json +3 -2
  35. package/radio/index.d.ts +1 -1
  36. package/radio/index.js +1 -4
  37. package/radio/radio.d.ts +4 -3
  38. package/radio/radio.js +6 -5
  39. package/radio/radio.stories.js +27 -13
  40. package/radio-group/index.d.ts +1 -1
  41. package/radio-group/index.js +1 -4
  42. package/radio-group/radio-group.d.ts +5 -10
  43. package/radio-group/radio-group.js +16 -12
  44. package/radio-group/radio-group.stories.d.ts +1 -1
  45. package/radio-group/radio-group.stories.js +12 -3
  46. package/toggle/index.d.ts +1 -0
  47. package/toggle/index.js +8 -0
  48. package/toggle/toggle.d.ts +9 -0
  49. package/toggle/toggle.js +15 -0
  50. package/toggle/toggle.stories.d.ts +8 -0
  51. package/toggle/toggle.stories.js +51 -0
@@ -0,0 +1,2 @@
1
+ import { UiContextType } from "../context";
2
+ export declare const getProviderConfig: () => UiContextType;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getProviderConfig = void 0;
4
+ const getProviderConfig = () => ({
5
+ icon: { spriteFilePath: "/icons-generated/_icon-sprite.svg", iconsConfig: { test: { w: 29.65, h: 40 } } },
6
+ });
7
+ exports.getProviderConfig = getProviderConfig;
@@ -4,11 +4,10 @@ import React, { AnchorHTMLAttributes } from "react";
4
4
  export declare type ButtonVariant = keyof ButtonVariants;
5
5
  export declare type ButtonSize = keyof ButtonSizes;
6
6
  export declare type ButtonColor = keyof ButtonColors;
7
- export interface ButtonProps extends AnchorHTMLAttributes<HTMLAnchorElement>, UseAnchorProps {
7
+ export interface ButtonProps extends Omit<AnchorHTMLAttributes<HTMLAnchorElement>, "type">, UseAnchorProps {
8
8
  color?: ButtonColor;
9
9
  isFullWidth?: boolean;
10
10
  size?: ButtonSize;
11
11
  variant?: ButtonVariant;
12
12
  }
13
- declare const _default: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLAnchorElement>>;
14
- export default _default;
13
+ export declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLAnchorElement>>;
package/button/button.js CHANGED
@@ -3,20 +3,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Button = void 0;
6
7
  const useAnchorProps_1 = require("@uxf/core/hooks/useAnchorProps");
7
8
  const cx_1 = require("@uxf/core/utils/cx");
8
9
  const react_1 = __importDefault(require("react"));
9
- const forward_ref_1 = require("../utils/forward-ref");
10
- function Button(props, ref) {
10
+ const forwardRef_1 = require("@uxf/core/utils/forwardRef");
11
+ exports.Button = (0, forwardRef_1.forwardRef)("Button", (props, ref) => {
11
12
  // eslint-disable-next-line react/destructuring-assignment
12
- const { color, isFullWidth, size, variant, ...restProps } = props;
13
- const className = (0, cx_1.cx)("uxf-button", `uxf-button--color-${color !== null && color !== void 0 ? color : "default"}`, `uxf-button--size-${size !== null && size !== void 0 ? size : "default"}`, `uxf-button--variant-${variant !== null && variant !== void 0 ? variant : "default"}`, isFullWidth && "uxf-button--full-width", props.className);
13
+ const { color, isFullWidth, size, variant, className, ...restProps } = props;
14
14
  const anchorProps = (0, useAnchorProps_1.useAnchorProps)({
15
15
  ...restProps,
16
- className,
16
+ className: (0, cx_1.cx)("uxf-button", `uxf-button--color-${color !== null && color !== void 0 ? color : "default"}`, `uxf-button--size-${size !== null && size !== void 0 ? size : "default"}`, `uxf-button--variant-${variant !== null && variant !== void 0 ? variant : "default"}`, isFullWidth && "uxf-button--full-width", className),
17
17
  });
18
18
  return (react_1.default.createElement("a", { ref: ref, ...anchorProps },
19
19
  typeof props.children === "string" ? (react_1.default.createElement("span", { className: "uxf-button__text" }, props.children)) : (props.children),
20
20
  react_1.default.createElement("div", { className: "loader" })));
21
- }
22
- exports.default = (0, forward_ref_1.forwardRef)("Button", Button);
21
+ });
package/button/index.d.ts CHANGED
@@ -1,2 +1 @@
1
- export { default as Button } from "@uxf/ui/button/button";
2
1
  export * from "@uxf/ui/button/button";
package/button/index.js CHANGED
@@ -13,11 +13,5 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
13
13
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
- var __importDefault = (this && this.__importDefault) || function (mod) {
17
- return (mod && mod.__esModule) ? mod : { "default": mod };
18
- };
19
16
  Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.Button = void 0;
21
- var button_1 = require("@uxf/ui/button/button");
22
- Object.defineProperty(exports, "Button", { enumerable: true, get: function () { return __importDefault(button_1).default; } });
23
17
  __exportStar(require("@uxf/ui/button/button"), exports);
@@ -1,12 +1,9 @@
1
- import { CSSProperties } from "react";
2
- interface Props {
1
+ import React, { CSSProperties } from "react";
2
+ import { FormControlProps } from "../types";
3
+ export interface CheckboxProps extends FormControlProps<boolean> {
3
4
  className?: string;
4
- checked: boolean;
5
- disabled?: boolean;
6
- intermediate?: boolean;
5
+ indeterminate?: boolean;
7
6
  label: string;
8
- onChange: (checked: boolean) => void;
9
7
  style?: Partial<CSSProperties>;
10
8
  }
11
- declare function Checkbox(props: Props): JSX.Element;
12
- export default Checkbox;
9
+ export declare const Checkbox: React.ForwardRefExoticComponent<CheckboxProps & React.RefAttributes<HTMLButtonElement>>;
@@ -3,21 +3,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Checkbox = void 0;
6
7
  const react_1 = require("@headlessui/react");
7
8
  const react_2 = __importDefault(require("react"));
8
9
  const cx_1 = require("@uxf/core/utils/cx");
9
10
  const classes_1 = require("@uxf/core/constants/classes");
11
+ const forwardRef_1 = require("@uxf/core/utils/forwardRef");
10
12
  function CheckIcon() {
11
- return (react_2.default.createElement("svg", { viewBox: "0 0 448 512", style: { height: 24 } },
12
- react_2.default.createElement("path", { fill: "currentColor", d: "M211.8 339.8C200.9 350.7 183.1 350.7 172.2 339.8L108.2 275.8C97.27 264.9 97.27 247.1 108.2 236.2C119.1 225.3 136.9 225.3 147.8 236.2L192 280.4L300.2 172.2C311.1 161.3 328.9 161.3 339.8 172.2C350.7 183.1 350.7 200.9 339.8 211.8L211.8 339.8zM0 96C0 60.65 28.65 32 64 32H384C419.3 32 448 60.65 448 96V416C448 451.3 419.3 480 384 480H64C28.65 480 0 451.3 0 416V96zM48 96V416C48 424.8 55.16 432 64 432H384C392.8 432 400 424.8 400 416V96C400 87.16 392.8 80 384 80H64C55.16 80 48 87.16 48 96z" })));
13
+ return (react_2.default.createElement("svg", { fill: "none", viewBox: "0 0 16 16" },
14
+ react_2.default.createElement("path", { d: "M13.333 4 6 11.333 2.667 8", stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2" })));
13
15
  }
14
- function SquareIcon() {
15
- return (react_2.default.createElement("svg", { viewBox: "0 0 448 512", style: { height: 24 } },
16
- react_2.default.createElement("path", { fill: "currentColor", d: "M384 32C419.3 32 448 60.65 448 96V416C448 451.3 419.3 480 384 480H64C28.65 480 0 451.3 0 416V96C0 60.65 28.65 32 64 32H384zM384 80H64C55.16 80 48 87.16 48 96V416C48 424.8 55.16 432 64 432H384C392.8 432 400 424.8 400 416V96C400 87.16 392.8 80 384 80z" })));
17
- }
18
- function Checkbox(props) {
19
- return (react_2.default.createElement(react_1.Switch, { checked: props.checked, className: (0, cx_1.cx)(props.checked && classes_1.CLASSES.IS_SELECTED, props.disabled && classes_1.CLASSES.IS_DISABLED, "uxf-checkbox", props.className), disabled: props.disabled, onChange: props.onChange, style: props.style },
16
+ exports.Checkbox = (0, forwardRef_1.forwardRef)("Checkbox", (props, ref) => {
17
+ return (react_2.default.createElement(react_1.Switch, { checked: props.value, className: (0, cx_1.cx)(props.value && classes_1.CLASSES.IS_SELECTED, props.isDisabled && classes_1.CLASSES.IS_DISABLED, props.isInvalid && classes_1.CLASSES.IS_INVALID, "uxf-checkbox", props.className), disabled: props.isDisabled, onChange: props.onChange, style: props.style, ref: ref },
20
18
  react_2.default.createElement("span", { className: "uxf-checkbox__label" }, props.label),
21
- props.checked ? react_2.default.createElement(CheckIcon, null) : react_2.default.createElement(SquareIcon, null)));
22
- }
23
- exports.default = Checkbox;
19
+ props.value && (react_2.default.createElement("span", { className: "uxf-checkbox__icon" },
20
+ react_2.default.createElement(CheckIcon, null)))));
21
+ });
@@ -1,8 +1,7 @@
1
- /// <reference types="react" />
2
- import { Checkbox } from "./index";
1
+ import React from "react";
3
2
  declare const _default: {
4
3
  title: string;
5
- component: typeof Checkbox;
4
+ component: React.ForwardRefExoticComponent<import("./checkbox").CheckboxProps & React.RefAttributes<HTMLButtonElement>>;
6
5
  };
7
6
  export default _default;
8
7
  export declare function Default(): JSX.Element;
@@ -32,9 +32,26 @@ exports.default = {
32
32
  };
33
33
  function Default() {
34
34
  const [checked, setChecked] = (0, react_1.useState)(true);
35
- return (react_1.default.createElement("div", { className: "space-y-2" },
36
- react_1.default.createElement(index_1.Checkbox, { label: "Opravdu?", onChange: () => {
37
- setChecked(!checked);
38
- }, checked: checked })));
35
+ return (react_1.default.createElement("div", { className: "flex" },
36
+ react_1.default.createElement("div", { className: "light flex gap-4 p-20" },
37
+ react_1.default.createElement(index_1.Checkbox, { label: "Opravdu?", onChange: () => {
38
+ setChecked((prev) => !prev);
39
+ }, value: checked }),
40
+ react_1.default.createElement(index_1.Checkbox, { label: "Opravdu?", isDisabled: true, onChange: () => {
41
+ setChecked((prev) => !prev);
42
+ }, value: checked }),
43
+ react_1.default.createElement(index_1.Checkbox, { label: "Opravdu?", isInvalid: true, onChange: () => {
44
+ setChecked((prev) => !prev);
45
+ }, value: checked })),
46
+ react_1.default.createElement("div", { className: "dark flex gap-4 bg-gray-900 p-20" },
47
+ react_1.default.createElement(index_1.Checkbox, { label: "Opravdu?", onChange: () => {
48
+ setChecked((prev) => !prev);
49
+ }, value: checked }),
50
+ react_1.default.createElement(index_1.Checkbox, { label: "Opravdu?", isDisabled: true, onChange: () => {
51
+ setChecked((prev) => !prev);
52
+ }, value: checked }),
53
+ react_1.default.createElement(index_1.Checkbox, { label: "Opravdu?", isInvalid: true, onChange: () => {
54
+ setChecked((prev) => !prev);
55
+ }, value: checked }))));
39
56
  }
40
57
  exports.Default = Default;
@@ -1 +1 @@
1
- export { default as Checkbox } from "./checkbox";
1
+ export { Checkbox } from "./checkbox";
package/checkbox/index.js CHANGED
@@ -1,8 +1,5 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.Checkbox = void 0;
7
4
  var checkbox_1 = require("./checkbox");
8
- Object.defineProperty(exports, "Checkbox", { enumerable: true, get: function () { return __importDefault(checkbox_1).default; } });
5
+ Object.defineProperty(exports, "Checkbox", { enumerable: true, get: function () { return checkbox_1.Checkbox; } });
@@ -0,0 +1,3 @@
1
+ export interface ContentSchema {
2
+ wysiwyg: any;
3
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,27 @@
1
+ import { ReactNode, FC } from "react";
2
+ import { ContentSchema } from "@uxf/ui/content/content-schema";
3
+ import { UseControllerProps } from "react-hook-form";
4
+ export declare type ContentType = keyof ContentSchema;
5
+ interface ContentFormProps<TYPE extends ContentType> extends UseControllerProps<ContentSchema[TYPE]> {
6
+ type: TYPE;
7
+ index: number;
8
+ onRemove: () => void;
9
+ TypeInputProps: any;
10
+ }
11
+ export declare type ContentFormComponent<TYPE extends ContentType> = FC<ContentFormProps<TYPE>> & {
12
+ getConfig: () => {
13
+ type: TYPE;
14
+ label: ReactNode;
15
+ };
16
+ };
17
+ interface ContentRendererProps<TYPE extends ContentType> {
18
+ type: TYPE;
19
+ data: ContentSchema[TYPE];
20
+ index: number;
21
+ }
22
+ export declare type ContentRendererComponent<TYPE extends ContentType> = FC<ContentRendererProps<TYPE>> & {
23
+ getConfig: () => {
24
+ type: TYPE;
25
+ };
26
+ };
27
+ export {};
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,12 @@
1
+ /// <reference types="react" />
2
+ import { IconName } from "../icon/types";
3
+ export declare type UiContextType = {
4
+ icon: {
5
+ spriteFilePath: string;
6
+ iconsConfig: Record<IconName, {
7
+ w: number;
8
+ h: number;
9
+ }>;
10
+ };
11
+ };
12
+ export declare const UiContext: import("react").Context<UiContextType | undefined>;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UiContext = void 0;
4
+ const react_1 = require("react");
5
+ exports.UiContext = (0, react_1.createContext)(undefined);
@@ -0,0 +1,3 @@
1
+ export * from "@uxf/ui/context/context";
2
+ export * from "@uxf/ui/context/provider";
3
+ export * from "@uxf/ui/context/use-component-context";
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("@uxf/ui/context/context"), exports);
18
+ __exportStar(require("@uxf/ui/context/provider"), exports);
19
+ __exportStar(require("@uxf/ui/context/use-component-context"), exports);
@@ -0,0 +1,8 @@
1
+ import { FC, ReactNode } from "react";
2
+ import { UiContextType } from "./context";
3
+ declare type UiContextProviderProps = {
4
+ value: UiContextType;
5
+ children: ReactNode;
6
+ };
7
+ export declare const UiContextProvider: FC<UiContextProviderProps>;
8
+ export {};
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.UiContextProvider = void 0;
7
+ const react_1 = __importDefault(require("react"));
8
+ const context_1 = require("./context");
9
+ const UiContextProvider = (props) => (react_1.default.createElement(context_1.UiContext.Provider, { value: props.value }, props.children));
10
+ exports.UiContextProvider = UiContextProvider;
@@ -0,0 +1,3 @@
1
+ import { UiContextType } from "./context";
2
+ export declare type UiContextComponent = keyof UiContextType;
3
+ export declare const useComponentContext: <T extends "icon">(componentName: T) => UiContextType[T];
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useComponentContext = void 0;
4
+ const react_1 = require("react");
5
+ const context_1 = require("./context");
6
+ const useComponentContext = (componentName) => {
7
+ const context = (0, react_1.useContext)(context_1.UiContext);
8
+ if (typeof context === "undefined") {
9
+ throw new Error(`If you want to use the "${componentName}" UI component, you have to wrap your code in the "UiContextProvider"`);
10
+ }
11
+ return context[componentName];
12
+ };
13
+ exports.useComponentContext = useComponentContext;
package/css/checkbox.css CHANGED
@@ -1,19 +1,85 @@
1
1
  .uxf-checkbox {
2
- @apply shrink-0 inline-flex items-center justify-center relative rounded-lg text-gray-300 h-6 w-6
3
- bg-white transition outline-none
4
- before:border before:absolute before:inset-0 before:rounded-lg before:border-current
5
- is-selected:text-indigo-600 is-selected:before:border-transparent is-selected:bg-current
6
- is-disabled:text-gray-300 is-selected:before:border-transparent
7
- is-invalid:text-red-600 is-invalid:before:border-transparent
8
- focus-visible:before:border-2 focus-visible:text-gray-800
9
- is-selected:hover:text-indigo-900 is-selected:is-invalid:hover:text-red-800
10
- is-selected:focus-visible:text-indigo-900
11
- is-selected:focus-visible:ring-indigo-600 is-selected:focus-visible:ring-2
12
- is-selected:is-invalid:focus-visible:text-red-800 is-selected:is-invalid:focus-visible:ring-red-600
13
- is-selected:is-invalid:focus-visible:ring-2;
2
+ @apply shrink-0 inline-flex items-center justify-center rounded h-6 w-6 transition outline-none border
3
+ focus-visible:ring-offset-2 focus-visible:ring-2;
14
4
 
15
5
  &__label {
16
6
  @apply sr-only;
17
7
  }
8
+
9
+ &__icon {
10
+ @apply w-4 h-4;
11
+ }
12
+
13
+ :root .light & {
14
+ @apply border-gray-400 focus-visible:ring-blue-500;
15
+
16
+ &.is-selected {
17
+ @apply bg-blue-500 border-none;
18
+
19
+ .uxf-checkbox__icon {
20
+ @apply text-white;
21
+ }
22
+ }
23
+
24
+ &.is-disabled {
25
+ @apply border-gray-200 pointer-events-none;
26
+
27
+ &.is-selected {
28
+ @apply bg-gray-200;
29
+ }
30
+
31
+ .uxf-checkbox__icon {
32
+ @apply text-gray-400;
33
+ }
34
+ }
35
+
36
+ &.is-invalid {
37
+ @apply border-red-600;
38
+
39
+ &.is-selected {
40
+ @apply bg-red-600;
41
+ }
42
+
43
+ .uxf-checkbox__icon {
44
+ @apply text-white;
45
+ }
46
+ }
47
+ }
48
+
49
+ :root .dark & {
50
+ @apply border-gray-400 focus-visible:ring-blue-500 focus-visible:ring-offset-gray-900;
51
+
52
+ &.is-selected {
53
+ @apply bg-blue-500 border-none;
54
+
55
+ .uxf-checkbox__icon {
56
+ @apply text-white;
57
+ }
58
+ }
59
+
60
+ &.is-disabled {
61
+ @apply border-gray-600 pointer-events-none;
62
+
63
+ &.is-selected {
64
+ @apply bg-gray-600;
65
+ }
66
+
67
+ .uxf-checkbox__icon {
68
+ @apply text-gray-800;
69
+ }
70
+ }
71
+
72
+ &.is-invalid {
73
+ @apply border-red-600;
74
+
75
+ &.is-selected {
76
+ @apply bg-red-600;
77
+ }
78
+
79
+ .uxf-checkbox__icon {
80
+ @apply text-white;
81
+ }
82
+ }
83
+ }
18
84
  }
19
85
 
@@ -1,8 +1,114 @@
1
1
  .uxf-radio-group {
2
- @apply bg-red-300;
2
+ &__option {
3
+ @apply outline-none focus-visible:ring-offset-2 focus-visible:ring-2 focus-visible:rounded-lg;
4
+ }
5
+
6
+ &__option__wrapper {
7
+ @apply flex justify-between;
8
+ }
9
+
10
+ &__option__label {
11
+ @apply line-clamp-2;
12
+ }
3
13
 
4
14
  &__label {
5
15
  @apply mb-2;
6
16
  }
17
+
18
+ &__label--hidden {
19
+ @apply sr-only;
20
+ }
21
+
22
+ :root .light & {
23
+ .uxf-radio-group__option {
24
+ @apply focus-visible:ring-blue-500 focus-visible:ring-offset-white;
25
+ }
26
+ }
27
+
28
+ :root .dark & {
29
+ .uxf-radio-group__option {
30
+ @apply focus-visible:ring-blue-500 focus-visible:ring-offset-gray-900;
31
+ }
32
+
33
+ .uxf-radio-group__option__label {
34
+ @apply text-white;
35
+ }
36
+ }
37
+ }
38
+
39
+ .uxf-radio-group--list {
40
+ .uxf-radio-group__options-wrapper {
41
+ @apply divide-y divide-gray-200;
42
+ }
43
+
44
+ .uxf-radio-group__option__wrapper {
45
+ @apply items-center py-4;
46
+ }
47
+
48
+ .uxf-radio-group__option__label {
49
+ @apply pr-4;
50
+ }
51
+
52
+ :root .light & {
53
+ .uxf-radio-group--list__option {
54
+ @apply focus-visible:ring-blue-500 focus-visible:ring-offset-white;
55
+ }
56
+ }
57
+
58
+ :root .dark & {
59
+ .uxf-radio-group--list__option {
60
+ @apply focus-visible:ring-blue-500 focus-visible:ring-offset-gray-900;
61
+ }
62
+
63
+ .uxf-radio-group--list__option__label {
64
+ @apply text-white;
65
+ }
66
+ }
67
+ }
68
+
69
+ .uxf-radio-group--radioButton {
70
+ .uxf-radio-group__options-wrapper {
71
+ @apply flex flex-wrap space-x-2;
72
+ }
73
+
74
+ .uxf-radio-group__option__wrapper {
75
+ @apply flex-col-reverse h-[82px] min-w-[112px] p-3 border rounded-lg;
76
+
77
+ &.is-selected {
78
+ @apply border-2;
79
+ }
80
+ }
81
+
82
+ :root .light & {
83
+ .uxf-radio-group__option {
84
+ @apply focus-visible:ring-blue-500;
85
+ }
86
+
87
+ .uxf-radio-group__option__wrapper {
88
+ @apply border-gray-400;
89
+
90
+ &.is-selected {
91
+ @apply border-blue-500;
92
+ }
93
+ }
94
+ }
95
+
96
+ :root .dark & {
97
+ .uxf-radio-group__option {
98
+ @apply focus-visible:ring-blue-500 focus-visible:ring-offset-gray-900;
99
+ }
100
+
101
+ .uxf-radio-group__option__wrapper {
102
+ @apply border-gray-400;
103
+
104
+ &.is-selected {
105
+ @apply border-blue-500;
106
+ }
107
+ }
108
+
109
+ .uxf-radio-group__option__label {
110
+ @apply text-white;
111
+ }
112
+ }
7
113
  }
8
114
 
package/css/radio.css CHANGED
@@ -1,20 +1,90 @@
1
1
  .uxf-radio {
2
- @apply h-4 w-4 border rounded-full border-gray-300 text-indigo-600;
2
+ @apply flex items-center justify-center h-6 w-6 border rounded-full transition;
3
3
 
4
- &.is-selected,.is-readonly {
5
- @apply border-primary-500 border-4;
4
+ &__label {
5
+ @apply sr-only;
6
6
  }
7
7
 
8
- &.is-invalid {
9
- @apply border-error-500;
8
+ &__inner {
9
+ @apply rounded-full h-2.5 w-2.5 opacity-0 transition;
10
10
  }
11
11
 
12
- &.is-disabled {
13
- @apply border-gray-200
12
+ &.is-selected {
13
+ .uxf-radio__inner {
14
+ @apply opacity-100;
15
+ }
14
16
  }
15
17
 
16
- &__inner {
17
- @apply bg-current rounded-full h-3.5 w-3.5 opacity-0 is-selected:opacity-100;
18
+ :root .light & {
19
+ @apply border-gray-400 focus-visible:ring-blue-500 focus-visible:ring-2;
20
+
21
+ &.is-selected {
22
+ @apply bg-blue-500 border-none;
23
+
24
+ .uxf-radio__inner {
25
+ @apply bg-white;
26
+ }
27
+ }
28
+
29
+ &.is-disabled {
30
+ @apply border-gray-200 pointer-events-none;
31
+
32
+ &.is-selected {
33
+ @apply bg-gray-200;
34
+ }
35
+
36
+ .uxf-radio__inner {
37
+ @apply bg-gray-400;
38
+ }
39
+ }
40
+
41
+ &.is-invalid {
42
+ @apply border-red-600;
43
+
44
+ &.is-selected {
45
+ @apply bg-red-600;
46
+ }
47
+
48
+ .uxf-radio__inner {
49
+ @apply bg-white;
50
+ }
51
+ }
52
+ }
53
+
54
+ :root .dark & {
55
+ @apply border-gray-400 focus-visible:ring-blue-500 focus-visible:ring-offset-gray-900;
56
+
57
+ &.is-selected {
58
+ @apply bg-blue-500 border-none;
59
+
60
+ .uxf-radio__inner {
61
+ @apply bg-white;
62
+ }
63
+ }
64
+
65
+ &.is-disabled {
66
+ @apply border-gray-600 pointer-events-none;
67
+
68
+ &.is-selected {
69
+ @apply bg-gray-600;
70
+ }
71
+
72
+ .uxf-radio__inner {
73
+ @apply bg-gray-800;
74
+ }
75
+ }
76
+
77
+ &.is-invalid {
78
+ @apply border-red-600;
79
+
80
+ &.is-selected {
81
+ @apply bg-red-600;
82
+ }
83
+
84
+ .uxf-radio__inner {
85
+ @apply bg-white;
86
+ }
87
+ }
18
88
  }
19
89
  }
20
90
 
package/css/toggle.css ADDED
@@ -0,0 +1,60 @@
1
+ .uxf-toggle {
2
+ @apply relative inline-flex h-6 w-12 items-center rounded-full p-0.5 outline-none ring-offset-2
3
+ focus-visible:ring-2;
4
+
5
+ &__label {
6
+ @apply sr-only;
7
+ }
8
+
9
+ &__inner {
10
+ @apply inline-block h-5 w-5 transform rounded-full bg-white transition;
11
+ }
12
+
13
+ &.is-selected {
14
+ .uxf-toggle__inner {
15
+ @apply translate-x-6;
16
+ }
17
+ }
18
+
19
+
20
+ :root .light & {
21
+ @apply bg-gray-200 focus-visible:ring-blue-500;
22
+
23
+ &__inner {
24
+ @apply bg-white;
25
+ }
26
+
27
+ &.is-selected {
28
+ @apply bg-blue-500;
29
+ }
30
+
31
+ &.is-disabled {
32
+ @apply bg-gray-100;
33
+
34
+ .uxf-toggle__inner {
35
+ @apply bg-gray-400;
36
+ }
37
+ }
38
+ }
39
+
40
+ :root .dark & {
41
+ @apply bg-gray-400 focus-visible:ring-blue-500 focus-visible:ring-offset-gray-900;
42
+
43
+ &.is-selected {
44
+ @apply bg-blue-500;
45
+ }
46
+
47
+ &__inner {
48
+ @apply bg-gray-900;
49
+ }
50
+
51
+ &.is-disabled {
52
+ @apply bg-gray-700;
53
+
54
+ .uxf-toggle__inner {
55
+ @apply bg-gray-500;
56
+ }
57
+ }
58
+ }
59
+ }
60
+
@@ -1,6 +1,6 @@
1
1
  import { UseAnchorProps } from "@uxf/core/hooks/useAnchorProps";
2
2
  import React, { AnchorHTMLAttributes, HTMLAttributes } from "react";
3
- interface ItemProps extends AnchorHTMLAttributes<HTMLAnchorElement>, UseAnchorProps {
3
+ interface ItemProps extends Omit<AnchorHTMLAttributes<HTMLAnchorElement>, "type">, UseAnchorProps {
4
4
  }
5
5
  declare type ItemsProps = HTMLAttributes<HTMLDivElement>;
6
6
  export declare const Dropdown: {
package/icon/icon.d.ts CHANGED
@@ -1,6 +1,5 @@
1
- import { IconsSet } from "@uxf/ui/icon/theme";
2
1
  import React, { CSSProperties } from "react";
3
- export declare type IconName = keyof IconsSet;
2
+ import { IconName } from "./types";
4
3
  declare type NameOrComponentType = {
5
4
  name: IconName;
6
5
  Component?: never;
package/icon/icon.js CHANGED
@@ -4,11 +4,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const react_1 = __importDefault(require("react"));
7
+ const context_1 = require("../context");
7
8
  const cx_1 = require("../utils/cx");
8
9
  const forward_ref_1 = require("../utils/forward-ref");
9
10
  const rem_1 = require("../utils/rem");
10
11
  function Icon(props, ref) {
11
12
  var _a, _b;
13
+ const componentContext = (0, context_1.useComponentContext)("icon");
12
14
  const CustomComponent = props.Component;
13
15
  const className = (0, cx_1.cx)("uxf-icon", props.className);
14
16
  const preserveAspectRatio = `xMidYMid ${(_a = props.mode) !== null && _a !== void 0 ? _a : "meet"}`;
@@ -19,7 +21,7 @@ function Icon(props, ref) {
19
21
  ...((_b = props.style) !== null && _b !== void 0 ? _b : {}),
20
22
  }
21
23
  : props.style;
22
- return CustomComponent ? (react_1.default.createElement(CustomComponent, { className: className, preserveAspectRatio: preserveAspectRatio, ref: ref, role: "img", style: style })) : (react_1.default.createElement("svg", { className: className, preserveAspectRatio: preserveAspectRatio, ref: ref, role: "img", style: style },
23
- react_1.default.createElement("use", { xlinkHref: `/icons-generated/_icon-sprite.svg#icon-sprite--${props.name}` })));
24
+ return CustomComponent ? (react_1.default.createElement(CustomComponent, { className: className, preserveAspectRatio: preserveAspectRatio, ref: ref, role: "img", style: style })) : (react_1.default.createElement("svg", { className: className, preserveAspectRatio: preserveAspectRatio, ref: ref, role: "img", style: style, viewBox: `0 0 ${componentContext.iconsConfig[props.name].w} ${componentContext.iconsConfig[props.name].h}` },
25
+ react_1.default.createElement("use", { xlinkHref: `${componentContext.spriteFilePath}#icon-sprite--${props.name}` })));
24
26
  }
25
27
  exports.default = (0, forward_ref_1.forwardRef)("Icon", Icon);
@@ -0,0 +1,2 @@
1
+ import { IconsSet } from "@uxf/ui/icon/theme";
2
+ export declare type IconName = keyof IconsSet;
package/icon/types.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uxf/ui",
3
- "version": "1.0.0-beta.55",
3
+ "version": "1.0.0-beta.57",
4
4
  "description": "",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -15,7 +15,8 @@
15
15
  "dependencies": {
16
16
  "@floating-ui/react-dom": "^1.0.0",
17
17
  "@headlessui/react": "^1.7.2",
18
- "@uxf/core": "^3.0.0",
18
+ "@uxf/core": "^3.1.0",
19
+ "@uxf/styles": "^2.0.0",
19
20
  "jump.js": "^1.0.2"
20
21
  },
21
22
  "devDependencies": {
package/radio/index.d.ts CHANGED
@@ -1 +1 @@
1
- export { default as Radio } from "./radio";
1
+ export { Radio } from "./radio";
package/radio/index.js CHANGED
@@ -1,8 +1,5 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.Radio = void 0;
7
4
  var radio_1 = require("./radio");
8
- Object.defineProperty(exports, "Radio", { enumerable: true, get: function () { return __importDefault(radio_1).default; } });
5
+ Object.defineProperty(exports, "Radio", { enumerable: true, get: function () { return radio_1.Radio; } });
package/radio/radio.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import React from "react";
2
2
  import { FormControlProps } from "../types";
3
- export declare type RadioProps = FormControlProps<boolean>;
4
- declare const _default: React.ForwardRefExoticComponent<RadioProps & React.RefAttributes<HTMLDivElement>>;
5
- export default _default;
3
+ export interface RadioProps extends FormControlProps<boolean> {
4
+ label: string;
5
+ }
6
+ export declare const Radio: React.ForwardRefExoticComponent<RadioProps & React.RefAttributes<HTMLDivElement>>;
package/radio/radio.js CHANGED
@@ -3,12 +3,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Radio = void 0;
6
7
  const classes_1 = require("@uxf/core/constants/classes");
7
8
  const cx_1 = require("@uxf/core/utils/cx");
8
9
  const react_1 = __importDefault(require("react"));
9
- const forward_ref_1 = require("../utils/forward-ref");
10
- function Radio(props, ref) {
11
- return (react_1.default.createElement("div", { ref: ref, className: (0, cx_1.cx)("uxf-radio", props.value && classes_1.CLASSES.IS_SELECTED, props.isDisabled && classes_1.CLASSES.IS_DISABLED, props.isInvalid && classes_1.CLASSES.IS_INVALID, props.isReadOnly && classes_1.CLASSES.IS_READONLY), onClick: () => { var _a; return (_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, !props.value); } },
10
+ const forwardRef_1 = require("@uxf/core/utils/forwardRef");
11
+ exports.Radio = (0, forwardRef_1.forwardRef)("Radio", (props, ref) => {
12
+ return (react_1.default.createElement("div", { className: (0, cx_1.cx)("uxf-radio", props.isDisabled && classes_1.CLASSES.IS_DISABLED, props.isInvalid && classes_1.CLASSES.IS_INVALID, props.isReadOnly && classes_1.CLASSES.IS_READONLY, props.value && classes_1.CLASSES.IS_SELECTED), onClick: () => { var _a; return (_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, !props.value); }, ref: ref },
13
+ react_1.default.createElement("span", { className: "uxf-radio__label" }, props.label),
12
14
  react_1.default.createElement("div", { className: "uxf-radio__inner" })));
13
- }
14
- exports.default = (0, forward_ref_1.forwardRef)("Radio", Radio);
15
+ });
@@ -11,18 +11,32 @@ exports.default = {
11
11
  component: index_1.Radio,
12
12
  };
13
13
  function Default() {
14
- return (react_1.default.createElement("div", null,
15
- react_1.default.createElement("div", { className: "mt-4 mb-2 font-semibold" }, "Default"),
16
- react_1.default.createElement("div", { className: "flex flex-row gap-4" },
17
- react_1.default.createElement(index_1.Radio, { value: false }),
18
- react_1.default.createElement(index_1.Radio, { value: true })),
19
- react_1.default.createElement("div", { className: "mt-4 mb-2 font-semibold" }, "Invalid"),
20
- react_1.default.createElement("div", { className: "flex flex-row gap-4" },
21
- react_1.default.createElement(index_1.Radio, { value: false, isInvalid: true }),
22
- react_1.default.createElement(index_1.Radio, { value: true, isInvalid: true })),
23
- react_1.default.createElement("div", { className: "mt-4 mb-2 font-semibold" }, "Disabled"),
24
- react_1.default.createElement("div", { className: "flex flex-row gap-4" },
25
- react_1.default.createElement(index_1.Radio, { value: false, isDisabled: true }),
26
- react_1.default.createElement(index_1.Radio, { value: true, isDisabled: true }))));
14
+ return (react_1.default.createElement("div", { className: "flex" },
15
+ react_1.default.createElement("div", { className: "light p-20" },
16
+ react_1.default.createElement("div", { className: "mt-4 mb-2 font-semibold" }, "Default"),
17
+ react_1.default.createElement("div", { className: "flex flex-row gap-4" },
18
+ react_1.default.createElement(index_1.Radio, { value: false, label: "Vyber" }),
19
+ react_1.default.createElement(index_1.Radio, { value: true, label: "Vyber" })),
20
+ react_1.default.createElement("div", { className: "mt-4 mb-2 font-semibold" }, "Invalid"),
21
+ react_1.default.createElement("div", { className: "flex flex-row gap-4" },
22
+ react_1.default.createElement(index_1.Radio, { value: false, label: "Vyber", isInvalid: true }),
23
+ react_1.default.createElement(index_1.Radio, { value: true, label: "Vyber", isInvalid: true })),
24
+ react_1.default.createElement("div", { className: "mt-4 mb-2 font-semibold" }, "Disabled"),
25
+ react_1.default.createElement("div", { className: "flex flex-row gap-4" },
26
+ react_1.default.createElement(index_1.Radio, { value: false, label: "Vyber", isDisabled: true }),
27
+ react_1.default.createElement(index_1.Radio, { value: true, label: "Vyber", isDisabled: true }))),
28
+ react_1.default.createElement("div", { className: "dark bg-gray-900 p-20" },
29
+ react_1.default.createElement("div", { className: "mt-4 mb-2 font-semibold text-white" }, "Default"),
30
+ react_1.default.createElement("div", { className: "flex flex-row gap-4" },
31
+ react_1.default.createElement(index_1.Radio, { value: false, label: "Vyber" }),
32
+ react_1.default.createElement(index_1.Radio, { value: true, label: "Vyber" })),
33
+ react_1.default.createElement("div", { className: "mt-4 mb-2 font-semibold text-white" }, "Invalid"),
34
+ react_1.default.createElement("div", { className: "flex flex-row gap-4" },
35
+ react_1.default.createElement(index_1.Radio, { value: false, label: "Vyber", isInvalid: true }),
36
+ react_1.default.createElement(index_1.Radio, { value: true, label: "Vyber", isInvalid: true })),
37
+ react_1.default.createElement("div", { className: "mt-4 mb-2 font-semibold text-white" }, "Disabled"),
38
+ react_1.default.createElement("div", { className: "flex flex-row gap-4" },
39
+ react_1.default.createElement(index_1.Radio, { value: false, label: "Vyber", isDisabled: true }),
40
+ react_1.default.createElement(index_1.Radio, { value: true, label: "Vyber", isDisabled: true })))));
27
41
  }
28
42
  exports.Default = Default;
@@ -1 +1 @@
1
- export { default as RadioGroup } from "./radio-group";
1
+ export { RadioGroup } from "./radio-group";
@@ -1,8 +1,5 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.RadioGroup = void 0;
7
4
  var radio_group_1 = require("./radio-group");
8
- Object.defineProperty(exports, "RadioGroup", { enumerable: true, get: function () { return __importDefault(radio_group_1).default; } });
5
+ Object.defineProperty(exports, "RadioGroup", { enumerable: true, get: function () { return radio_group_1.RadioGroup; } });
@@ -1,25 +1,20 @@
1
- import React, { CSSProperties, FocusEventHandler } from "react";
1
+ import React, { CSSProperties } from "react";
2
+ import { FormControlProps } from "../types";
2
3
  export declare type RadioGroupOptionValue = string | number;
3
4
  export interface RadioGroupOption {
4
5
  disabled?: boolean;
5
6
  label: string;
6
7
  value: RadioGroupOptionValue;
7
8
  }
8
- export interface RadioGroupProps {
9
+ export interface RadioGroupProps extends FormControlProps<RadioGroupOptionValue | null> {
9
10
  className?: string;
10
- disabled?: boolean;
11
11
  error?: string;
12
12
  forceColumn?: boolean;
13
13
  hiddenLabel?: boolean;
14
14
  id: string;
15
- invalid?: boolean;
16
15
  label: string;
17
- onBlur?: FocusEventHandler<HTMLDivElement>;
18
- onChange: (value: RadioGroupOptionValue) => void;
19
- onFocus?: FocusEventHandler<HTMLDivElement>;
20
16
  options: RadioGroupOption[];
21
17
  style?: CSSProperties;
22
- value?: RadioGroupOptionValue | null;
18
+ variant?: "list" | "radioButton";
23
19
  }
24
- declare const _default: React.ForwardRefExoticComponent<RadioGroupProps & React.RefAttributes<HTMLDivElement>>;
25
- export default _default;
20
+ export declare const RadioGroup: React.ForwardRefExoticComponent<RadioGroupProps & React.RefAttributes<HTMLLabelElement>>;
@@ -23,23 +23,27 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.RadioGroup = void 0;
26
27
  const react_1 = require("@headlessui/react");
27
- const composeRefs_1 = require("@uxf/core/utils/composeRefs");
28
28
  const react_2 = __importStar(require("react"));
29
29
  const error_message_1 = require("../error-message");
30
30
  const use_input_submit_1 = require("../hooks/use-input-submit");
31
31
  const label_1 = require("../label");
32
32
  const radio_1 = require("../radio");
33
- const forward_ref_1 = require("../utils/forward-ref");
34
- function RadioGroup(props, ref) {
33
+ const cx_1 = require("@uxf/core/utils/cx");
34
+ const classes_1 = require("@uxf/core/constants/classes");
35
+ const forwardRef_1 = require("@uxf/core/utils/forwardRef");
36
+ exports.RadioGroup = (0, forwardRef_1.forwardRef)("RadioGroup", (props, ref) => {
35
37
  // eslint-disable-next-line react/destructuring-assignment
36
- const { className, disabled, error, forceColumn, hiddenLabel, id, invalid, label, onBlur, onChange, onFocus, options, style, value, } = props;
38
+ const { isDisabled, error, hiddenLabel, id, isInvalid, label, onChange, options, style, value, variant = "list", } = props;
37
39
  const innerRef = (0, react_2.useRef)(null);
38
- (0, use_input_submit_1.useInputSubmit)(innerRef, "radio-group", disabled);
39
- const errorId = invalid ? `${id}--errormessage` : undefined;
40
- return (react_2.default.createElement(react_1.RadioGroup, { className: `_form-field ${className || ""}`, disabled: disabled, id: id, value: value, onChange: onChange, style: style },
41
- !hiddenLabel && (react_2.default.createElement(react_1.RadioGroup.Label, { as: label_1.Label, className: "uxf-radio-group__label" }, label)),
42
- react_2.default.createElement("div", { className: `flex ${forceColumn ? "flex-col" : "flex-wrap items-center"} focus-visible:ring-gray-dark outline-none focus-visible:ring-2`, onBlur: onBlur, onFocus: onFocus, ref: (0, composeRefs_1.composeRefs)(innerRef, ref), tabIndex: disabled ? -1 : 0 }, options.map((option) => (react_2.default.createElement(react_1.RadioGroup.Option, { as: react_2.Fragment, disabled: option.disabled, key: option.value.toString(), value: option.value }, (o) => react_2.default.createElement(radio_1.Radio, { value: o.checked, isDisabled: disabled || o.disabled, isInvalid: invalid }))))),
43
- invalid && error && react_2.default.createElement(error_message_1.ErrorMessage, { id: errorId }, error)));
44
- }
45
- exports.default = (0, forward_ref_1.forwardRef)("RadioGroup", RadioGroup);
40
+ (0, use_input_submit_1.useInputSubmit)(innerRef, "radio-group", isDisabled);
41
+ const errorId = isInvalid ? `${id}--errormessage` : undefined;
42
+ const rootClassName = (0, cx_1.cx)("uxf-radio-group", variant === "list" && "uxf-radio-group--list", variant === "radioButton" && "uxf-radio-group--radioButton", isDisabled && classes_1.CLASSES.IS_DISABLED, isInvalid && classes_1.CLASSES.IS_INVALID);
43
+ return (react_2.default.createElement(react_1.RadioGroup, { className: rootClassName, disabled: isDisabled, id: id, onChange: onChange, style: style, value: value },
44
+ react_2.default.createElement(react_1.RadioGroup.Label, { as: label_1.Label, className: `uxf-radio-group__label ${hiddenLabel ? "uxf-radio-group__label--hidden" : ""}`, ref: ref }, label),
45
+ react_2.default.createElement("div", { className: "uxf-radio-group__options-wrapper" }, options.map((option) => (react_2.default.createElement(react_1.RadioGroup.Option, { className: (0, cx_1.cx)("uxf-radio-group__option", props.isDisabled && classes_1.CLASSES.IS_DISABLED), disabled: option.disabled, key: option.value.toString(), value: option.value }, (o) => (react_2.default.createElement("div", { className: (0, cx_1.cx)("uxf-radio-group__option__wrapper", o.checked && classes_1.CLASSES.IS_SELECTED) },
46
+ react_2.default.createElement("span", { className: "uxf-radio-group__option__label" }, option.label),
47
+ react_2.default.createElement(radio_1.Radio, { isDisabled: isDisabled || o.disabled, isInvalid: isInvalid, label: option.label, ref: o.checked ? innerRef : undefined, value: o.checked }))))))),
48
+ isInvalid && error && react_2.default.createElement(error_message_1.ErrorMessage, { id: errorId }, error)));
49
+ });
@@ -1,7 +1,7 @@
1
1
  import React from "react";
2
2
  declare const _default: {
3
3
  title: string;
4
- component: React.ForwardRefExoticComponent<import("./radio-group").RadioGroupProps & React.RefAttributes<HTMLDivElement>>;
4
+ component: React.ForwardRefExoticComponent<import("./radio-group").RadioGroupProps & React.RefAttributes<HTMLLabelElement>>;
5
5
  };
6
6
  export default _default;
7
7
  export declare function Default(): JSX.Element;
@@ -41,12 +41,21 @@ const options = [
41
41
  },
42
42
  {
43
43
  value: "3",
44
- label: "Radio three",
44
+ label: "Radio three-sixty",
45
45
  },
46
46
  ];
47
47
  function Default() {
48
48
  const [value, setValue] = (0, react_1.useState)(options[0].value);
49
- return (react_1.default.createElement("div", { className: "space-y-2" },
50
- react_1.default.createElement(index_1.RadioGroup, { id: "radiogroup", options: options, label: "Radio group", value: value, onChange: setValue })));
49
+ return (react_1.default.createElement(react_1.default.Fragment, null,
50
+ react_1.default.createElement("div", { className: "space-z-2 flex" },
51
+ react_1.default.createElement("div", { className: "light w-1/2 p-20" },
52
+ react_1.default.createElement(index_1.RadioGroup, { id: "radiogroup", label: "Light Radio group", onChange: (v) => setValue(v), options: options, value: value })),
53
+ react_1.default.createElement("div", { className: "dark w-1/2 bg-gray-900 p-20" },
54
+ react_1.default.createElement(index_1.RadioGroup, { id: "radiogroup", label: "Dark Radio group", onChange: (v) => setValue(v), options: options, value: value }))),
55
+ react_1.default.createElement("div", { className: "space-z-2 flex" },
56
+ react_1.default.createElement("div", { className: "light w-1/2 p-20" },
57
+ react_1.default.createElement(index_1.RadioGroup, { id: "radiogroup", label: "Light Radio group radio button", onChange: (v) => setValue(v), options: options, value: value, variant: "radioButton" })),
58
+ react_1.default.createElement("div", { className: "dark w-1/2 bg-gray-900 p-20" },
59
+ react_1.default.createElement(index_1.RadioGroup, { id: "radiogroup", label: "Dark Radio group radio button", onChange: (v) => setValue(v), options: options, value: value, variant: "radioButton" })))));
51
60
  }
52
61
  exports.Default = Default;
@@ -0,0 +1 @@
1
+ export { default as Toggle } from "./toggle";
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Toggle = void 0;
7
+ var toggle_1 = require("./toggle");
8
+ Object.defineProperty(exports, "Toggle", { enumerable: true, get: function () { return __importDefault(toggle_1).default; } });
@@ -0,0 +1,9 @@
1
+ import { CSSProperties } from "react";
2
+ import { FormControlProps } from "../types";
3
+ export interface ToggleProps extends FormControlProps<boolean> {
4
+ className?: string;
5
+ label: string;
6
+ style?: Partial<CSSProperties>;
7
+ }
8
+ declare function Toggle(props: ToggleProps): JSX.Element;
9
+ export default Toggle;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const react_1 = require("@headlessui/react");
7
+ const react_2 = __importDefault(require("react"));
8
+ const cx_1 = require("@uxf/core/utils/cx");
9
+ const classes_1 = require("@uxf/core/constants/classes");
10
+ function Toggle(props) {
11
+ return (react_2.default.createElement(react_1.Switch, { checked: props.value, className: (0, cx_1.cx)(props.value && classes_1.CLASSES.IS_SELECTED, props.isDisabled && classes_1.CLASSES.IS_DISABLED, "uxf-toggle", props.className), disabled: props.isDisabled, onChange: props.onChange, style: props.style },
12
+ react_2.default.createElement("span", { className: "uxf-toggle__label" }, props.label),
13
+ react_2.default.createElement("span", { className: "uxf-toggle__inner" })));
14
+ }
15
+ exports.default = Toggle;
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ import { Toggle } from "./index";
3
+ declare const _default: {
4
+ title: string;
5
+ component: typeof Toggle;
6
+ };
7
+ export default _default;
8
+ export declare function Default(): JSX.Element;
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.Default = void 0;
27
+ const index_1 = require("./index");
28
+ const react_1 = __importStar(require("react"));
29
+ exports.default = {
30
+ title: "UI/Toggle",
31
+ component: index_1.Toggle,
32
+ };
33
+ function Default() {
34
+ const [checked, setChecked] = (0, react_1.useState)(true);
35
+ return (react_1.default.createElement("div", { className: "flex" },
36
+ react_1.default.createElement("div", { className: "light flex gap-4 p-20" },
37
+ react_1.default.createElement(index_1.Toggle, { label: "Opravdu?", onChange: () => {
38
+ setChecked((prev) => !prev);
39
+ }, value: checked }),
40
+ react_1.default.createElement(index_1.Toggle, { label: "Opravdu?", onChange: () => {
41
+ setChecked((prev) => !prev);
42
+ }, value: checked, isDisabled: true })),
43
+ react_1.default.createElement("div", { className: "dark flex gap-4 bg-gray-900 p-20" },
44
+ react_1.default.createElement(index_1.Toggle, { label: "Opravdu?", onChange: () => {
45
+ setChecked((prev) => !prev);
46
+ }, value: checked }),
47
+ react_1.default.createElement(index_1.Toggle, { label: "Opravdu?", onChange: () => {
48
+ setChecked((prev) => !prev);
49
+ }, value: checked, isDisabled: true }))));
50
+ }
51
+ exports.Default = Default;