@koobiq/react-components 0.0.1-beta.20 → 0.0.1-beta.21

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.
@@ -35,6 +35,7 @@ export type AlertBaseProps = {
35
35
  icon?: ReactNode;
36
36
  /** A callback function called when the user clicks the alert's close button. */
37
37
  onClose?: IconButtonProps['onPress'];
38
+ /** The props used for each slot inside. */
38
39
  slotProps?: {
39
40
  content?: ComponentPropsWithRef<'div'>;
40
41
  statusIcon?: ComponentPropsWithRef<'div'>;
@@ -15,8 +15,8 @@ export declare const DialogCloseButton: import("react").ForwardRefExoticComponen
15
15
  startIcon?: import("react").ReactNode;
16
16
  endIcon?: import("react").ReactNode;
17
17
  'data-testid'?: string | number;
18
- onHoverStart?: (e: import("@react-types/shared").HoverEvent) => void;
19
- onHoverEnd?: (e: import("@react-types/shared").HoverEvent) => void;
18
+ onHoverStart?: (e: import("@koobiq/react-primitives").HoverEvent) => void;
19
+ onHoverEnd?: (e: import("@koobiq/react-primitives").HoverEvent) => void;
20
20
  } & {
21
21
  as?: "button" | undefined;
22
22
  }, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
@@ -0,0 +1,24 @@
1
+ import type { ComponentPropsWithRef, CSSProperties, ReactNode } from 'react';
2
+ import type { ItemProps as AriaItemProps } from '@koobiq/react-primitives';
3
+ import type { IconButtonProps } from '../IconButton';
4
+ export type TagProps<T> = AriaItemProps<T> & {
5
+ /** Additional CSS-classes. */
6
+ className?: string;
7
+ /** Inline styles. */
8
+ style?: CSSProperties;
9
+ /** Unique identifier for testing purposes. */
10
+ 'data-testid'?: string | number;
11
+ /** Icon placed before the children. */
12
+ icon?: ReactNode;
13
+ /** The props used for each slot inside. */
14
+ slotProps?: {
15
+ root?: ComponentPropsWithRef<'div'>;
16
+ icon?: ComponentPropsWithRef<'span'>;
17
+ content?: ComponentPropsWithRef<'span'>;
18
+ removeIcon?: IconButtonProps;
19
+ };
20
+ };
21
+ export declare function Tag<T>(_props: TagProps<T>): null;
22
+ export declare namespace Tag {
23
+ var getCollectionNode: unknown;
24
+ }
@@ -0,0 +1,10 @@
1
+ "use client";
2
+ import { Item } from "@koobiq/react-primitives";
3
+ const ItemInner = Item;
4
+ function Tag(_props) {
5
+ return null;
6
+ }
7
+ Tag.getCollectionNode = ItemInner.getCollectionNode;
8
+ export {
9
+ Tag
10
+ };
@@ -0,0 +1,2 @@
1
+ import type { TagGroupComponentProp } from './types';
2
+ export declare const TagGroup: TagGroupComponentProp;
@@ -0,0 +1,22 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { forwardRef } from "react";
3
+ import { useDOMRef, mergeProps, clsx } from "@koobiq/react-core";
4
+ import { useListState, useTagGroup } from "@koobiq/react-primitives";
5
+ import s from "./TagGroup.module.css.js";
6
+ import { TagInner } from "./components/TagInner/TagInner.js";
7
+ function TagGroupRender(props, ref) {
8
+ const { variant = "theme-fade", style, className, slotProps } = props;
9
+ const domRef = useDOMRef(ref);
10
+ const state = useListState(props);
11
+ const { gridProps } = useTagGroup(props, state, domRef);
12
+ const rootProps = mergeProps(
13
+ { className: clsx(s.base, className), style, ref: domRef },
14
+ gridProps,
15
+ slotProps?.root
16
+ );
17
+ return /* @__PURE__ */ jsx("div", { ...rootProps, children: [...state.collection].map((item) => /* @__PURE__ */ jsx(TagInner, { item, variant, state }, item.key)) });
18
+ }
19
+ const TagGroup = forwardRef(TagGroupRender);
20
+ export {
21
+ TagGroup
22
+ };
@@ -0,0 +1,8 @@
1
+ const base = "kbq-taggroup-20136b";
2
+ const s = {
3
+ base
4
+ };
5
+ export {
6
+ base,
7
+ s as default
8
+ };
@@ -0,0 +1,11 @@
1
+ import { type AriaTagProps, type ListState } from '@koobiq/react-primitives';
2
+ import type { TagGroupPropVariant } from '../../index';
3
+ export type TagInnerProps<T> = AriaTagProps<T> & {
4
+ state: ListState<T>;
5
+ /**
6
+ * The variant to use.
7
+ * @default theme-fade
8
+ * */
9
+ variant?: TagGroupPropVariant;
10
+ };
11
+ export declare function TagInner<T>(props: TagInnerProps<T>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,86 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { useRef } from "react";
3
+ import { useFocusRing, useHover, mergeProps, clsx, isNotNil } from "@koobiq/react-core";
4
+ import { IconXmarkS16 } from "@koobiq/react-icons";
5
+ import { useLocalizedStringFormatter, useTag } from "@koobiq/react-primitives";
6
+ import { utilClasses } from "../../../../styles/utility.js";
7
+ import intlMessages from "../../intl.json.js";
8
+ import s from "./TagInner.module.css.js";
9
+ import { matchVariantToCloseButton } from "./utils.js";
10
+ import { IconButton } from "../../../IconButton/IconButton.js";
11
+ const textNormalMedium = utilClasses.typography["text-normal-medium"];
12
+ function TagInner(props) {
13
+ const { item, state, variant = "theme-fade" } = props;
14
+ const { slotProps, icon, className, style } = item.props;
15
+ const ref = useRef(null);
16
+ const stringFormatter = useLocalizedStringFormatter(intlMessages);
17
+ const { focusProps, isFocusVisible, isFocused } = useFocusRing({
18
+ within: false
19
+ });
20
+ const {
21
+ rowProps,
22
+ gridCellProps,
23
+ removeButtonProps: removeButtonPropsAria,
24
+ allowsRemoving,
25
+ isDisabled,
26
+ isPressed
27
+ } = useTag(props, state, ref);
28
+ const { hoverProps, isHovered } = useHover({ isDisabled });
29
+ const rootProps = mergeProps(
30
+ {
31
+ className: clsx(
32
+ s.base,
33
+ s[variant],
34
+ isFocused && s.focused,
35
+ isHovered && s.hovered,
36
+ isDisabled && s.disabled,
37
+ textNormalMedium,
38
+ className
39
+ ),
40
+ style,
41
+ "data-variant": variant,
42
+ "data-focused": isFocused,
43
+ "data-pressed": isPressed,
44
+ "data-hovered": isHovered,
45
+ "aria-disabled": isDisabled,
46
+ "data-disabled": isDisabled,
47
+ "data-focus-visible": isFocusVisible
48
+ },
49
+ rowProps,
50
+ hoverProps,
51
+ focusProps,
52
+ slotProps?.root
53
+ );
54
+ const removeButtonProps = mergeProps(
55
+ {
56
+ tabIndex: -1,
57
+ compact: true,
58
+ disabled: isDisabled,
59
+ className: s.cancelIcon,
60
+ variant: matchVariantToCloseButton[variant],
61
+ "aria-label": stringFormatter.format("close")
62
+ },
63
+ removeButtonPropsAria,
64
+ slotProps?.removeIcon
65
+ );
66
+ const contentProps = mergeProps(
67
+ {
68
+ className: s.content
69
+ },
70
+ slotProps?.content
71
+ );
72
+ const iconProps = mergeProps(
73
+ {
74
+ className: s.icon
75
+ },
76
+ slotProps?.icon
77
+ );
78
+ return /* @__PURE__ */ jsx("div", { ref, ...rootProps, children: /* @__PURE__ */ jsxs("div", { ...gridCellProps, children: [
79
+ isNotNil(icon) && /* @__PURE__ */ jsx("span", { ...iconProps, children: icon }),
80
+ isNotNil(item.rendered) && /* @__PURE__ */ jsx("span", { ...contentProps, children: item.rendered }),
81
+ allowsRemoving && /* @__PURE__ */ jsx(IconButton, { size: "l", ...removeButtonProps, children: /* @__PURE__ */ jsx(IconXmarkS16, {}) })
82
+ ] }) });
83
+ }
84
+ export {
85
+ TagInner
86
+ };
@@ -0,0 +1,30 @@
1
+ const base = "kbq-taginner-f9f19a";
2
+ const content = "kbq-taginner-content-72ca39";
3
+ const icon = "kbq-taginner-icon-df45be";
4
+ const cancelIcon = "kbq-taginner-cancelIcon-8a3dbe";
5
+ const hovered = "kbq-taginner-hovered-abf199";
6
+ const focused = "kbq-taginner-focused-16f44f";
7
+ const disabled = "kbq-taginner-disabled-0c6073";
8
+ const s = {
9
+ base,
10
+ content,
11
+ icon,
12
+ cancelIcon,
13
+ "theme-fade": "kbq-taginner-theme-fade-68b99c",
14
+ "contrast-fade": "kbq-taginner-contrast-fade-39d7a7",
15
+ "error-fade": "kbq-taginner-error-fade-6d7d03",
16
+ "warning-fade": "kbq-taginner-warning-fade-9403c7",
17
+ hovered,
18
+ focused,
19
+ disabled
20
+ };
21
+ export {
22
+ base,
23
+ cancelIcon,
24
+ content,
25
+ s as default,
26
+ disabled,
27
+ focused,
28
+ hovered,
29
+ icon
30
+ };
@@ -0,0 +1 @@
1
+ export * from './TagInner';
@@ -0,0 +1,3 @@
1
+ import type { IconButtonPropVariant } from '../../../IconButton';
2
+ import type { TagGroupPropVariant } from '../../types';
3
+ export declare const matchVariantToCloseButton: Record<TagGroupPropVariant, IconButtonPropVariant>;
@@ -0,0 +1,9 @@
1
+ const matchVariantToCloseButton = {
2
+ "theme-fade": "theme",
3
+ "contrast-fade": "fade-contrast",
4
+ "error-fade": "error",
5
+ "warning-fade": "warning"
6
+ };
7
+ export {
8
+ matchVariantToCloseButton
9
+ };
@@ -0,0 +1 @@
1
+ export * from './TagInner';
@@ -0,0 +1,3 @@
1
+ export * from './TagGroup';
2
+ export * from './Tag';
3
+ export * from './types';
@@ -0,0 +1,7 @@
1
+ const intlMessages = {
2
+ "ru-RU": { "close": "Закрыть" },
3
+ "en-US": { "close": "Close" }
4
+ };
5
+ export {
6
+ intlMessages as default
7
+ };
@@ -0,0 +1,37 @@
1
+ import type { ComponentPropsWithRef, ComponentRef, CSSProperties, ReactElement, Ref } from 'react';
2
+ import type { AriaTagGroupProps } from '@koobiq/react-primitives';
3
+ export type TagGroupPropChildren<T extends object> = AriaTagGroupProps<T>['children'];
4
+ export type TagGroupPropItems<T extends object> = AriaTagGroupProps<T>['items'];
5
+ export type TagGroupPropOnRemove<T extends object> = AriaTagGroupProps<T>['onRemove'];
6
+ export type TagGroupPropDisabledKeys<T extends object> = AriaTagGroupProps<T>['disabledKeys'];
7
+ export declare const tagGroupPropVariant: readonly ["theme-fade", "contrast-fade", "error-fade", "warning-fade"];
8
+ export type TagGroupPropVariant = (typeof tagGroupPropVariant)[number];
9
+ export type TagGroupProps<T extends object> = {
10
+ /** The contents of the collection. */
11
+ children?: TagGroupPropChildren<T>;
12
+ /** Item objects in the collection. */
13
+ items?: TagGroupPropItems<T>;
14
+ /** Handler that is called when a user deletes a tag. */
15
+ onRemove?: TagGroupPropOnRemove<T>;
16
+ /**
17
+ * The variant to use.
18
+ * @default theme-fade
19
+ * */
20
+ variant?: TagGroupPropVariant;
21
+ /** The item keys that are disabled. These items cannot be selected, focused, or otherwise interacted with. */
22
+ disabledKeys?: TagGroupPropDisabledKeys<T>;
23
+ /** Ref to the HTML ul-element. */
24
+ ref?: Ref<HTMLElement>;
25
+ /** Additional CSS-classes. */
26
+ className?: string;
27
+ /** Unique identifier for testing purposes. */
28
+ 'data-testid'?: string | number;
29
+ /** Inline styles. */
30
+ style?: CSSProperties;
31
+ /** The props used for each slot inside. */
32
+ slotProps?: {
33
+ root?: ComponentPropsWithRef<'div'>;
34
+ };
35
+ };
36
+ export type TagGroupComponentProp = <T extends object>(props: TagGroupProps<T>) => ReactElement | null;
37
+ export type TagGroupRef = ComponentRef<'div'>;
@@ -0,0 +1,9 @@
1
+ const tagGroupPropVariant = [
2
+ "theme-fade",
3
+ "contrast-fade",
4
+ "error-fade",
5
+ "warning-fade"
6
+ ];
7
+ export {
8
+ tagGroupPropVariant
9
+ };
@@ -28,4 +28,6 @@ export * from './Select';
28
28
  export * from './Divider';
29
29
  export * from './Menu';
30
30
  export * from './ButtonToggleGroup';
31
+ export * from './TagGroup';
31
32
  export * from './layout';
33
+ export { useListData } from '@koobiq/react-primitives';
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  /* empty css */
2
+ import { useListData } from "@koobiq/react-primitives";
2
3
  import { Provider, defaultBreakpoints } from "./components/Provider/Provider.js";
3
4
  import { BreakpointsProvider } from "./components/Provider/BreakpointsProvider.js";
4
5
  import { ProviderContext, useProvider } from "./components/Provider/ProviderContext.js";
@@ -67,6 +68,9 @@ import { Menu } from "./components/Menu/Menu.js";
67
68
  import { menuPropSelectionMode } from "./components/Menu/types.js";
68
69
  import { ButtonToggleGroup } from "./components/ButtonToggleGroup/ButtonToggleGroup.js";
69
70
  import { ButtonToggle } from "./components/ButtonToggleGroup/components/ButtonToggle/ButtonToggle.js";
71
+ import { TagGroup } from "./components/TagGroup/TagGroup.js";
72
+ import { Tag } from "./components/TagGroup/Tag.js";
73
+ import { tagGroupPropVariant } from "./components/TagGroup/types.js";
70
74
  import { flex, flexPropAlignItems, flexPropDirection, flexPropFlex, flexPropGap, flexPropJustifyContent, flexPropOrder, flexPropWrap } from "./components/layout/flex/flex.js";
71
75
  import { spacing, spacingGap } from "./components/layout/spacing/spacing.js";
72
76
  export {
@@ -119,6 +123,8 @@ export {
119
123
  SidePanelHeader,
120
124
  SkeletonBlock,
121
125
  SkeletonTypography,
126
+ Tag,
127
+ TagGroup,
122
128
  Textarea,
123
129
  Toggle,
124
130
  Tooltip,
@@ -164,6 +170,7 @@ export {
164
170
  sidePanelPropSize,
165
171
  spacing,
166
172
  spacingGap,
173
+ tagGroupPropVariant,
167
174
  textareaPropExpand,
168
175
  textareaPropVariant,
169
176
  togglePropLabelPlacement,
@@ -175,6 +182,7 @@ export {
175
182
  typographyPropDisplay,
176
183
  typographyPropVariant,
177
184
  useBreakpoints,
185
+ useListData,
178
186
  useMatchedBreakpoints,
179
187
  useProvider,
180
188
  useRadioGroupState
package/dist/style.css CHANGED
@@ -3333,6 +3333,114 @@
3333
3333
  text-overflow: ellipsis;
3334
3334
  overflow: hidden;
3335
3335
  }
3336
+ .kbq-taggroup-20136b {
3337
+ gap: var(--kbq-size-s);
3338
+ flex-wrap: wrap;
3339
+ display: flex;
3340
+ }
3341
+
3342
+ .kbq-taggroup-20136b [role="gridcell"] {
3343
+ display: contents;
3344
+ }
3345
+ .kbq-taginner-f9f19a {
3346
+ --tag-color: ;
3347
+ --tag-bg-color: ;
3348
+ --tag-icon-color: ;
3349
+ --tag-outline-color: transparent;
3350
+ --tag-outline-width: var(--kbq-size-3xs);
3351
+ cursor: default;
3352
+ vertical-align: top;
3353
+ white-space: nowrap;
3354
+ box-sizing: border-box;
3355
+ color: var(--tag-color);
3356
+ align-items: center;
3357
+ gap: var(--kbq-size-3xs);
3358
+ block-size: var(--kbq-size-xxl);
3359
+ border-radius: var(--kbq-size-xxs);
3360
+ padding-inline: var(--kbq-size-xxs);
3361
+ min-inline-size: var(--kbq-size-xxl);
3362
+ background-color: var(--tag-bg-color);
3363
+ outline: var(--tag-outline-width) solid var(--tag-outline-color);
3364
+ transition: outline-color var(--kbq-transition-default), background-color var(--kbq-transition-default), color var(--kbq-transition-default);
3365
+ border: none;
3366
+ text-decoration: none;
3367
+ display: inline-flex;
3368
+ }
3369
+
3370
+ .kbq-taginner-content-72ca39 {
3371
+ white-space: nowrap;
3372
+ text-overflow: ellipsis;
3373
+ margin-inline: var(--kbq-size-3xs);
3374
+ overflow: hidden;
3375
+ }
3376
+
3377
+ .kbq-taginner-icon-df45be {
3378
+ color: var(--tag-icon-color);
3379
+ flex-shrink: 0;
3380
+ justify-content: center;
3381
+ align-items: center;
3382
+ margin-inline-start: var(--kbq-size-3xs);
3383
+ display: flex;
3384
+ }
3385
+
3386
+ .kbq-taginner-cancelIcon-8a3dbe {
3387
+ justify-content: center;
3388
+ align-items: center;
3389
+ margin-inline-end: var(--kbq-size-3xs);
3390
+ display: flex;
3391
+ }
3392
+
3393
+ .kbq-taginner-theme-fade-68b99c {
3394
+ --tag-icon-color: var(--kbq-icon-theme);
3395
+ --tag-bg-color: var(--kbq-background-theme-fade);
3396
+ --tag-color: var(--kbq-foreground-theme);
3397
+ }
3398
+
3399
+ .kbq-taginner-contrast-fade-39d7a7 {
3400
+ --tag-icon-color: var(--kbq-icon-contrast-fade);
3401
+ --tag-bg-color: var(--kbq-background-contrast-fade);
3402
+ --tag-color: var(--kbq-foreground-contrast);
3403
+ }
3404
+
3405
+ .kbq-taginner-error-fade-6d7d03 {
3406
+ --tag-icon-color: var(--kbq-icon-error);
3407
+ --tag-bg-color: var(--kbq-background-error-fade);
3408
+ --tag-color: var(--kbq-foreground-error);
3409
+ }
3410
+
3411
+ .kbq-taginner-warning-fade-9403c7 {
3412
+ --tag-icon-color: var(--kbq-icon-warning);
3413
+ --tag-bg-color: var(--kbq-background-warning-fade);
3414
+ --tag-color: var(--kbq-foreground-warning);
3415
+ }
3416
+
3417
+ .kbq-taginner-theme-fade-68b99c:where(.kbq-taginner-hovered-abf199) {
3418
+ --tag-bg-color: var(--kbq-states-background-theme-fade-hover);
3419
+ }
3420
+
3421
+ .kbq-taginner-contrast-fade-39d7a7:where(.kbq-taginner-hovered-abf199) {
3422
+ --tag-bg-color: var(--kbq-states-background-contrast-fade-hover);
3423
+ }
3424
+
3425
+ .kbq-taginner-error-fade-6d7d03:where(.kbq-taginner-hovered-abf199) {
3426
+ --tag-bg-color: var(--kbq-states-background-error-fade-hover);
3427
+ }
3428
+
3429
+ .kbq-taginner-warning-fade-9403c7:where(.kbq-taginner-hovered-abf199) {
3430
+ --tag-bg-color: var(--kbq-states-background-warning-fade-hover);
3431
+ }
3432
+
3433
+ .kbq-taginner-focused-16f44f {
3434
+ --tag-outline-color: var(--kbq-states-line-focus-theme);
3435
+ }
3436
+
3437
+ .kbq-taginner-disabled-0c6073 {
3438
+ --tag-icon-color: ;
3439
+ --tag-bg-color: var(--kbq-states-background-disabled);
3440
+ --tag-color: var(--kbq-states-foreground-disabled);
3441
+ --tag-outline-color: none;
3442
+ cursor: not-allowed;
3443
+ }
3336
3444
  .kbq-spacing-mbs_0-be7021 {
3337
3445
  margin-block-start: 0;
3338
3446
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@koobiq/react-components",
3
- "version": "0.0.1-beta.20",
3
+ "version": "0.0.1-beta.21",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "exports": {
@@ -27,10 +27,10 @@
27
27
  "@koobiq/design-tokens": "^3.12.1",
28
28
  "@types/react-transition-group": "^4.4.12",
29
29
  "react-transition-group": "^4.4.5",
30
- "@koobiq/react-core": "0.0.1-beta.20",
31
- "@koobiq/logger": "0.0.1-beta.20",
32
- "@koobiq/react-icons": "0.0.1-beta.20",
33
- "@koobiq/react-primitives": "0.0.1-beta.20"
30
+ "@koobiq/logger": "0.0.1-beta.21",
31
+ "@koobiq/react-icons": "0.0.1-beta.21",
32
+ "@koobiq/react-primitives": "0.0.1-beta.21",
33
+ "@koobiq/react-core": "0.0.1-beta.21"
34
34
  },
35
35
  "peerDependencies": {
36
36
  "@koobiq/design-tokens": "^3.11.2",