@koobiq/react-components 0.0.1-beta.7 → 0.0.1-beta.8

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 (29) hide show
  1. package/dist/components/AnimatedIcon/AnimatedIcon.d.ts +4 -0
  2. package/dist/components/AnimatedIcon/AnimatedIcon.js +50 -0
  3. package/dist/components/AnimatedIcon/AnimatedIcon.module.css.js +11 -0
  4. package/dist/components/AnimatedIcon/index.d.ts +2 -0
  5. package/dist/components/AnimatedIcon/types.d.ts +19 -0
  6. package/dist/components/Checkbox/Checkbox.js +17 -7
  7. package/dist/components/FieldComponents/FieldInputGroup/FieldInputGroup.d.ts +2 -2
  8. package/dist/components/Input/Input.d.ts +1 -0
  9. package/dist/components/Input/Input.js +9 -9
  10. package/dist/components/Input/types.d.ts +2 -1
  11. package/dist/components/index.d.ts +1 -0
  12. package/dist/index.js +2 -0
  13. package/dist/style.css +43 -1
  14. package/package.json +5 -5
  15. package/dist/components/Input/components/FieldAddon/FieldAddon.d.ts +0 -10
  16. package/dist/components/Input/components/FieldAddon/index.d.ts +0 -1
  17. package/dist/components/Input/components/FieldCaption/FieldCaption.d.ts +0 -6
  18. package/dist/components/Input/components/FieldCaption/index.d.ts +0 -1
  19. package/dist/components/Input/components/FieldControl/FieldControl.d.ts +0 -9
  20. package/dist/components/Input/components/FieldControl/index.d.ts +0 -1
  21. package/dist/components/Input/components/FieldError/FieldError.d.ts +0 -7
  22. package/dist/components/Input/components/FieldError/index.d.ts +0 -1
  23. package/dist/components/Input/components/FieldInput/FieldInput.d.ts +0 -9
  24. package/dist/components/Input/components/FieldInput/index.d.ts +0 -1
  25. package/dist/components/Input/components/FieldInputGroup/FieldInputGroup.d.ts +0 -7
  26. package/dist/components/Input/components/FieldInputGroup/index.d.ts +0 -1
  27. package/dist/components/Input/components/FieldLabel/FieldLabel.d.ts +0 -9
  28. package/dist/components/Input/components/FieldLabel/index.d.ts +0 -1
  29. package/dist/components/Input/components/index.d.ts +0 -7
@@ -0,0 +1,4 @@
1
+ import type { ComponentPropsWithRef, ElementType } from 'react';
2
+ import type { AnimatedIconBaseProps } from './index';
3
+ export declare const AnimatedIcon: import("@koobiq/react-core").PolyForwardComponent<"span", AnimatedIconBaseProps, ElementType>;
4
+ export type AnimatedIconProps<As extends ElementType = 'span'> = ComponentPropsWithRef<typeof AnimatedIcon<As>>;
@@ -0,0 +1,50 @@
1
+ "use client";
2
+ import { jsx } from "react/jsx-runtime";
3
+ import { polymorphicForwardRef, useRefs, clsx } from "@koobiq/react-core";
4
+ import { Transition } from "react-transition-group";
5
+ import s from "./AnimatedIcon.module.css.js";
6
+ const AnimatedIcon = polymorphicForwardRef((props, ref) => {
7
+ const {
8
+ transition = 300,
9
+ as: Tag = "span",
10
+ activeIndex = 0,
11
+ directions,
12
+ className,
13
+ icons = [],
14
+ style: styleProp,
15
+ ...other
16
+ } = props;
17
+ const refs = useRefs(icons.length);
18
+ const singleIcon = icons?.[0];
19
+ const innerRender = icons.length === 1 ? singleIcon : icons.map((icon, index) => /* @__PURE__ */ jsx(
20
+ Transition,
21
+ {
22
+ in: activeIndex === index,
23
+ timeout: transition,
24
+ nodeRef: refs[index],
25
+ unmountOnExit: true,
26
+ children: (transition2) => /* @__PURE__ */ jsx(
27
+ "span",
28
+ {
29
+ className: s.icon,
30
+ "data-index": index,
31
+ ref: refs[index],
32
+ "data-transition": transition2,
33
+ children: icon
34
+ }
35
+ )
36
+ },
37
+ index
38
+ ));
39
+ const style = {
40
+ ...styleProp,
41
+ "--animated-icon-transition": `${transition}ms`,
42
+ ...typeof directions?.[activeIndex] === "number" && {
43
+ "--animated-icon-direction": `rotate(${directions[activeIndex]}deg)`
44
+ }
45
+ };
46
+ return /* @__PURE__ */ jsx(Tag, { ...other, className: clsx(s.base, className), style, ref, children: innerRender });
47
+ });
48
+ export {
49
+ AnimatedIcon
50
+ };
@@ -0,0 +1,11 @@
1
+ const base = "kbq-animatedicon-61fd86";
2
+ const icon = "kbq-animatedicon-icon-2feff8";
3
+ const s = {
4
+ base,
5
+ icon
6
+ };
7
+ export {
8
+ base,
9
+ s as default,
10
+ icon
11
+ };
@@ -0,0 +1,2 @@
1
+ export * from './AnimatedIcon';
2
+ export * from './types';
@@ -0,0 +1,19 @@
1
+ import type { ComponentRef, CSSProperties, ReactNode } from 'react';
2
+ export type AnimatedIconBaseProps = {
3
+ /** A list of icons. */
4
+ icons?: ReactNode[];
5
+ /** A list of directions for the icons. */
6
+ directions?: number[];
7
+ /**
8
+ * Animation duration in milliseconds.
9
+ * @default 300
10
+ * */
11
+ transition?: number;
12
+ /** Index of the active icon. */
13
+ activeIndex?: number;
14
+ /** Additional CSS-classes. */
15
+ className?: string;
16
+ /** Inline styles. */
17
+ style?: CSSProperties;
18
+ };
19
+ export type AnimatedIconRef = ComponentRef<'span'>;
@@ -5,6 +5,7 @@ import { mergeProps, clsx, isNotNil } from "@koobiq/react-core";
5
5
  import { IconCheckS16, IconMinusS16 } from "@koobiq/react-icons";
6
6
  import { Checkbox as Checkbox$1 } from "@koobiq/react-primitives";
7
7
  import s from "./Checkbox.module.css.js";
8
+ import { AnimatedIcon } from "../AnimatedIcon/AnimatedIcon.js";
8
9
  const Checkbox = forwardRef(
9
10
  (props, ref) => {
10
11
  const {
@@ -47,13 +48,22 @@ const Checkbox = forwardRef(
47
48
  "data-indeterminate": indeterminate,
48
49
  ...commonProps,
49
50
  ref,
50
- children: ({ checked, indeterminate: indeterminate2 }) => /* @__PURE__ */ jsxs(Fragment, { children: [
51
- /* @__PURE__ */ jsxs("span", { ...boxProps, children: [
52
- checked && !indeterminate2 && /* @__PURE__ */ jsx(IconCheckS16, {}),
53
- indeterminate2 && /* @__PURE__ */ jsx(IconMinusS16, {})
54
- ] }),
55
- isNotNil(children) && /* @__PURE__ */ jsx("span", { ...labelProps, children })
56
- ] })
51
+ children: ({ checked, indeterminate: indeterminate2 }) => {
52
+ const activeIndex = indeterminate2 ? 1 : Number(Boolean(checked)) - 1;
53
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
54
+ /* @__PURE__ */ jsx("span", { ...boxProps, children: /* @__PURE__ */ jsx(
55
+ AnimatedIcon,
56
+ {
57
+ icons: [
58
+ /* @__PURE__ */ jsx(IconCheckS16, {}, "checked"),
59
+ /* @__PURE__ */ jsx(IconMinusS16, {}, "indeterminate")
60
+ ],
61
+ activeIndex
62
+ }
63
+ ) }),
64
+ isNotNil(children) && /* @__PURE__ */ jsx("span", { ...labelProps, children })
65
+ ] });
66
+ }
57
67
  }
58
68
  );
59
69
  }
@@ -1,6 +1,6 @@
1
1
  import { type ReactNode } from 'react';
2
2
  import { type ExtendableComponentPropsWithRef } from '@koobiq/react-core';
3
- export type FieldInputGroupBaseProps = ExtendableComponentPropsWithRef<{
3
+ export type FieldInputGroupProps = ExtendableComponentPropsWithRef<{
4
4
  children?: ReactNode;
5
5
  startAddon?: ReactNode;
6
6
  endAddon?: ReactNode;
@@ -8,4 +8,4 @@ export type FieldInputGroupBaseProps = ExtendableComponentPropsWithRef<{
8
8
  className?: string;
9
9
  error?: boolean;
10
10
  }, 'div'>;
11
- export declare const FieldInputGroup: import("react").ForwardRefExoticComponent<Omit<FieldInputGroupBaseProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
11
+ export declare const FieldInputGroup: import("react").ForwardRefExoticComponent<Omit<FieldInputGroupProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
@@ -17,6 +17,7 @@ export declare const Input: import("react").ForwardRefExoticComponent<Omit<Omit<
17
17
  label?: import("../FieldComponents").FieldLabelProps;
18
18
  input?: import("../FieldComponents").FieldInputProps;
19
19
  caption?: import("../FieldComponents").FieldCaptionProps;
20
+ group?: import("../FieldComponents").FieldInputGroupProps;
20
21
  errorMessage?: import("../FieldComponents").FieldErrorProps;
21
22
  };
22
23
  } & import("react").RefAttributes<HTMLInputElement>>;
@@ -46,19 +46,19 @@ const Input = forwardRef((props, ref) => {
46
46
  },
47
47
  slotProps?.input
48
48
  );
49
+ const groupProps = mergeProps(
50
+ {
51
+ error,
52
+ endAddon,
53
+ startAddon
54
+ },
55
+ slotProps?.group
56
+ );
49
57
  const captionProps = slotProps?.caption;
50
58
  const errorProps = mergeProps({ error }, slotProps?.errorMessage);
51
59
  return /* @__PURE__ */ jsxs(Fragment, { children: [
52
60
  /* @__PURE__ */ jsx(FieldLabel, { ...labelProps, children: labelProps?.children || label }),
53
- /* @__PURE__ */ jsx(
54
- FieldInputGroup,
55
- {
56
- error,
57
- endAddon,
58
- startAddon,
59
- children: /* @__PURE__ */ jsx(FieldInput, { ...inputProps })
60
- }
61
- ),
61
+ /* @__PURE__ */ jsx(FieldInputGroup, { ...groupProps, children: /* @__PURE__ */ jsx(FieldInput, { ...inputProps }) }),
62
62
  /* @__PURE__ */ jsx(FieldCaption, { ...captionProps, children: captionProps?.children || caption }),
63
63
  /* @__PURE__ */ jsx(FieldError, { ...errorProps, children: errorProps.children || errorMessage })
64
64
  ] });
@@ -1,7 +1,7 @@
1
1
  import type { ComponentRef, CSSProperties, ReactNode } from 'react';
2
2
  import type { ExtendableProps } from '@koobiq/react-core';
3
3
  import type { UseTextFieldProps } from '@koobiq/react-primitives';
4
- import type { FieldCaptionProps, FieldErrorProps, FieldInputProps, FieldLabelProps } from '../FieldComponents';
4
+ import type { FieldCaptionProps, FieldErrorProps, FieldInputProps, FieldLabelProps, FieldInputGroupProps } from '../FieldComponents';
5
5
  export declare const inputPropVariant: readonly ["filled", "transparent"];
6
6
  export type InputPropVariant = (typeof inputPropVariant)[number];
7
7
  export type InputProps = ExtendableProps<{
@@ -56,6 +56,7 @@ export type InputProps = ExtendableProps<{
56
56
  label?: FieldLabelProps;
57
57
  input?: FieldInputProps;
58
58
  caption?: FieldCaptionProps;
59
+ group?: FieldInputGroupProps;
59
60
  errorMessage?: FieldErrorProps;
60
61
  };
61
62
  }, Omit<UseTextFieldProps, 'inputElementType'>>;
@@ -23,4 +23,5 @@ export * from './SidePanel';
23
23
  export * from './Popover';
24
24
  export * from './Tooltip';
25
25
  export * from './List';
26
+ export * from './AnimatedIcon';
26
27
  export * from './layout';
package/dist/index.js CHANGED
@@ -58,10 +58,12 @@ import { List, ListRender } from "./components/List/List.js";
58
58
  import { listPropSelectionMode } from "./components/List/types.js";
59
59
  import { ListItem } from "./components/List/ListItem.js";
60
60
  import { ListSection } from "./components/List/ListSection.js";
61
+ import { AnimatedIcon } from "./components/AnimatedIcon/AnimatedIcon.js";
61
62
  import { flex, flexPropAlignItems, flexPropDirection, flexPropFlex, flexPropGap, flexPropJustifyContent, flexPropOrder, flexPropWrap } from "./components/layout/flex/flex.js";
62
63
  import { spacing, spacingGap } from "./components/layout/spacing/spacing.js";
63
64
  export {
64
65
  Alert,
66
+ AnimatedIcon,
65
67
  Badge,
66
68
  BreakpointsContext,
67
69
  BreakpointsProvider,
package/dist/style.css CHANGED
@@ -1497,6 +1497,46 @@
1497
1497
  .kbq-checkbox-end-0c77de {
1498
1498
  flex-direction: row;
1499
1499
  }
1500
+ .kbq-animatedicon-61fd86 {
1501
+ --animated-icon-direction: ;
1502
+ --animated-icon-transition-function: cubic-bezier(.7, 0, .5, 1);
1503
+ --animated-icon-transition: .3s;
1504
+ transition: transform var(--animated-icon-transition) var(--animated-icon-transition-function);
1505
+ transform: var(--animated-icon-direction);
1506
+ justify-content: center;
1507
+ align-items: center;
1508
+ display: inline-flex;
1509
+ position: relative;
1510
+ }
1511
+
1512
+ .kbq-animatedicon-icon-2feff8 {
1513
+ transition: transform var(--animated-icon-transition) var(--animated-icon-transition-function), opacity var(--animated-icon-transition) var(--animated-icon-transition-function);
1514
+ justify-content: center;
1515
+ align-items: center;
1516
+ display: inline-flex;
1517
+ }
1518
+
1519
+ .kbq-animatedicon-icon-2feff8[data-transition="entering"] {
1520
+ opacity: 1;
1521
+ position: absolute;
1522
+ transform: scale(1);
1523
+ }
1524
+
1525
+ .kbq-animatedicon-icon-2feff8[data-transition="entered"] {
1526
+ opacity: 1;
1527
+ transform: scale(1);
1528
+ }
1529
+
1530
+ .kbq-animatedicon-icon-2feff8[data-transition="exiting"] {
1531
+ opacity: 0;
1532
+ position: absolute;
1533
+ transform: scale(.1);
1534
+ }
1535
+
1536
+ .kbq-animatedicon-icon-2feff8[data-transition="exited"] {
1537
+ opacity: 0;
1538
+ transform: scale(.1);
1539
+ }
1500
1540
  .kbq-link-093ccd {
1501
1541
  --link-gap: var(--kbq-size-xxs);
1502
1542
  --link-outline-width: var(--kbq-size-3xs);
@@ -2503,6 +2543,7 @@
2503
2543
  outline: none;
2504
2544
  flex-direction: column;
2505
2545
  flex-grow: 1;
2546
+ min-block-size: 48px;
2506
2547
  display: flex;
2507
2548
  position: relative;
2508
2549
  }
@@ -2688,7 +2729,6 @@
2688
2729
  .kbq-popover-f14dc5 {
2689
2730
  --popover-inline-size: ;
2690
2731
  border-radius: var(--kbq-size-m);
2691
- min-block-size: 48px;
2692
2732
  box-shadow: var(--kbq-shadow-overlay);
2693
2733
  background-color: var(--kbq-background-bg);
2694
2734
  inline-size: var(--popover-inline-size);
@@ -2922,6 +2962,7 @@
2922
2962
  }
2923
2963
 
2924
2964
  .kbq-listsection-heading-5bd9e3 {
2965
+ box-sizing: border-box;
2925
2966
  padding: var(--kbq-size-s) var(--kbq-size-m);
2926
2967
  }
2927
2968
  .kbq-listoption-8693c5 {
@@ -2929,6 +2970,7 @@
2929
2970
  --list-item-outline-color: transparent;
2930
2971
  --list-item-outline-width: var(--kbq-size-3xs);
2931
2972
  cursor: pointer;
2973
+ box-sizing: border-box;
2932
2974
  gap: var(--kbq-size-s);
2933
2975
  border-radius: var(--kbq-size-s);
2934
2976
  color: var(--kbq-foreground-contrast);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@koobiq/react-components",
3
- "version": "0.0.1-beta.7",
3
+ "version": "0.0.1-beta.8",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "exports": {
@@ -22,10 +22,10 @@
22
22
  "@koobiq/design-tokens": "^3.12.1",
23
23
  "@types/react-transition-group": "^4.4.12",
24
24
  "react-transition-group": "^4.4.5",
25
- "@koobiq/logger": "0.0.1-beta.7",
26
- "@koobiq/react-icons": "0.0.1-beta.7",
27
- "@koobiq/react-core": "0.0.1-beta.7",
28
- "@koobiq/react-primitives": "0.0.1-beta.7"
25
+ "@koobiq/logger": "0.0.1-beta.8",
26
+ "@koobiq/react-core": "0.0.1-beta.8",
27
+ "@koobiq/react-icons": "0.0.1-beta.8",
28
+ "@koobiq/react-primitives": "0.0.1-beta.8"
29
29
  },
30
30
  "peerDependencies": {
31
31
  "@koobiq/design-tokens": "^3.11.2",
@@ -1,10 +0,0 @@
1
- import type { ReactNode } from 'react';
2
- import type { ExtendableComponentPropsWithRef } from '@koobiq/react-core';
3
- export declare const fieldAddonPropPlacement: readonly ["start", "end"];
4
- export type FieldAddonPlacement = (typeof fieldAddonPropPlacement)[number];
5
- export type FieldAddonProps = ExtendableComponentPropsWithRef<{
6
- children?: ReactNode;
7
- placement?: FieldAddonPlacement;
8
- error?: boolean;
9
- }, 'div'>;
10
- export declare const FieldAddon: import("react").ForwardRefExoticComponent<Omit<FieldAddonProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
@@ -1 +0,0 @@
1
- export * from './FieldAddon';
@@ -1,6 +0,0 @@
1
- import type { ReactNode } from 'react';
2
- import type { ExtendableComponentPropsWithRef } from '@koobiq/react-core';
3
- export type FieldCaptionProps = ExtendableComponentPropsWithRef<{
4
- children?: ReactNode;
5
- }, 'div'>;
6
- export declare const FieldCaption: import("react").ForwardRefExoticComponent<Omit<FieldCaptionProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
@@ -1 +0,0 @@
1
- export * from './FieldCaption';
@@ -1,9 +0,0 @@
1
- import type { ReactNode } from 'react';
2
- import { type ExtendableComponentPropsWithRef } from '@koobiq/react-core';
3
- export type FieldControlProps = ExtendableComponentPropsWithRef<{
4
- children?: ReactNode;
5
- fullWidth?: boolean;
6
- error?: boolean;
7
- className?: string;
8
- }, 'div'>;
9
- export declare const FieldControl: import("react").ForwardRefExoticComponent<Omit<FieldControlProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
@@ -1 +0,0 @@
1
- export * from './FieldControl';
@@ -1,7 +0,0 @@
1
- import type { ReactNode } from 'react';
2
- import type { ExtendableComponentPropsWithRef } from '@koobiq/react-core';
3
- export type FieldErrorProps = ExtendableComponentPropsWithRef<{
4
- children?: ReactNode;
5
- error?: boolean;
6
- }, 'div'>;
7
- export declare const FieldError: import("react").ForwardRefExoticComponent<Omit<FieldErrorProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
@@ -1 +0,0 @@
1
- export * from './FieldError';
@@ -1,9 +0,0 @@
1
- import type { useTextField } from '@koobiq/react-primitives';
2
- import type { InputPropVariant } from '../../types';
3
- export type FieldInputProps = {
4
- error?: boolean;
5
- variant?: InputPropVariant;
6
- disabled?: boolean;
7
- className?: string;
8
- } & ReturnType<typeof useTextField>['inputProps'];
9
- export declare const FieldInput: import("@koobiq/react-core").PolyForwardComponent<"input", FieldInputProps, import("react").ElementType>;
@@ -1 +0,0 @@
1
- export * from './FieldInput';
@@ -1,7 +0,0 @@
1
- import type { ReactNode } from 'react';
2
- import { type ExtendableComponentPropsWithRef } from '@koobiq/react-core';
3
- export type FieldInputGroupProps = ExtendableComponentPropsWithRef<{
4
- children?: ReactNode;
5
- className?: string;
6
- }, 'div'>;
7
- export declare const FieldInputGroup: import("react").ForwardRefExoticComponent<Omit<FieldInputGroupProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
@@ -1 +0,0 @@
1
- export * from './FieldInputGroup';
@@ -1,9 +0,0 @@
1
- import type { ReactNode } from 'react';
2
- import type { ExtendableComponentPropsWithRef } from '@koobiq/react-core';
3
- export type FieldLabelProps = ExtendableComponentPropsWithRef<{
4
- children?: ReactNode;
5
- className?: string;
6
- hiddenLabel?: boolean;
7
- required?: boolean;
8
- }, 'label'>;
9
- export declare const FieldLabel: import("react").ForwardRefExoticComponent<Omit<FieldLabelProps, "ref"> & import("react").RefAttributes<HTMLLabelElement>>;
@@ -1 +0,0 @@
1
- export * from './FieldLabel';
@@ -1,7 +0,0 @@
1
- export * from './FieldControl';
2
- export * from './FieldInput';
3
- export * from './FieldLabel';
4
- export * from './FieldAddon';
5
- export * from './FieldCaption';
6
- export * from './FieldError';
7
- export * from './FieldInputGroup';